# FAQ: Loops - Introduction to Loops

This community-built FAQ covers the “Introduction to Loops” exercise from the lesson “Loops”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## FAQs on the exercise Introduction to Loops

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I’m stuck, I need help. I know this isn’t apart of the exercise, but my calculator is only returning the actual third number of what I inputted, not the difference. If you run this code, you’ll see exactly what I’m talking about. Note: Please input “+” as your first operator, because that’s the part I’m working on and then “-”.

#include
#include

using namespace std;

int main() {
char op;
char opS;
double num1;
double num2;
double num3;

``````// Title
std::cout << "-Calculator-\n";

std::cout << "Enter your first number.\n";
std::cin >> num1;

std::cout << "Enter either of these operators: +, -, /, or *\n";
std::cin >> op;

std::cout << "Enter your second number.\n";
std::cin >> num2;

double storedNum1;

switch(op)
{
case '+':
num1+num2==storedNum1;
std::cout << "\n* , /, + or - this number? If not, enter 'exit'\n";

std::cin >> opS;

switch(opS)
{
case '-':
std::cout << "Enter your third number.";
std::cin >> num3;
std::cout << num3-storedNum1 << " is the answer.";

}

break;

case '-':
break;

case '*':
break;

case '/':
break;

default:

std::cout << "Operator isn't valid. Try again.\n";
break;
}
char c;
std::cin >> c;
return 0;
``````

}

1 Like

Btw I can say your code is messed up little a bit. What do you mean by `num1+num2==storedNum1;` ? I think you are trying to sum `num1` and `num2` and then assign to a variable `storedNum1` but that’s not the right way of doing it. You can do this `storedNum1 = num1 + num2;`

Also, I will suggest you go through `lvalue` & `rvalue` topics

1 Like

here I guess you mean storedNum1 = num1+num2;