Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3215796
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:13:10+00:00 2026-05-17T15:13:10+00:00

I have an equation with 4 variables, I am prompting the user to enter

  • 0

I have an equation with 4 variables, I am prompting the user to enter each one of these variables, and then the program decides based on what variables are entered, which variables it needs to solve for. For instance, given variable a and b, I need to solve for b and c. I am trying to come up with a way for the program to decide which variables have been entered, and which ones have not been. This is what I have been thinking so far:

int a,b,c,d;
char unknown;
cout<<"****This program decides which variables to solve for****\n;
cout<<"Please enter the known variables below, if a variable is unknown, 
please enter a'?'\n"
cout<< "please enter variable a\n";
cin>>a;
cout<< "please enter variable b\n";
cin>>b;
etc....
if (a =='?'){
 check b,c,d}
if (b =='?'){
 check c,d}

And then running those variables through if statements to determine which variables are present and which aren’t. There has to be an easier way though, these if else if statements have the potential to be ridiculous. If any of you have any advice its much appreciated. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:13:11+00:00Added an answer on May 17, 2026 at 3:13 pm

    The pseudo-code that you’ve posted won’t work, because >>x where xis an int will try to interpret the user’s input as a specification of an integer. So, with the user typing ? what happens is that the operation fails, cin is put in a failure state, and further input operations are ignored until or if that failure state is cleared.

    One way around this is to input a line at a time, into a std::string, by using std::getline from the <string> header. When you have the line of input you can then check whether it’s a question mark (or simpler, just empty). And if not you can then attempt to convert the user’s number specification to an int by using e.g. a std::istringstream (as I recall from the <sstream> header).

    It can be instructive to make this part work even if you’ll probably discover, as “Potatoswatter” commented, that the problem you’re doing this for can be quite complex.

    Cheers & hth.,

    – Alf

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following simple equation in my C# program to convert a number
I am making a program that solves an equation. I have a variable that
I have string with some equation, that include variables. For example: eq='(a+1)*c-d' Also I
I have an equation which I try to plot and work with in Mathematica
I have an underdetermined equation set (m equations of n variables, m smaller than
I have an equation which has been reduced to the form eqn1 := f(x,y,z)
I have a collection of variables in Python, some of which are normal Python
I have the equation of a 2D line in the General Form a x
I would like to have an equation to calculate, per zoom level on the
I have a class that solves an equation using an approximation, evaluates the approximation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.