I need help with this. I am brand new to coding and I am trying to make a calculator but it keeps infinitely looping after it asks to if you want to make another question. If someone could show me what I am doing wrong or any tips in general please do.
do{
18 do{
19 cout << "\nInput any number: ";
20 cin >> a;
21 cout << "\nChoose an operation ( + - * / or X for Exit and C for Clear): ";
22 cin >> Operator;
23 }while(Operator=='C');
your do-while statement closes with a while statement that is set to TRUE (==). That's my opinion.
If im not right about the first comment I made. Im pretty sure Im "just" on this one...It's always good to initialize your local variables to 0
if (z >= -2000000000000) {
cout << "Would you like to start another problem?: ";
cin >> Problem;
switch (Problem) {
case'Yes':
case'yes':
cout << "Previous answer was: " << z;
if (y>0) {
cout << " and " << y << " Remainder" << endl;
}
break;
case'No':
case'no':
terminate();
break;
}
}
} while (z >= -200000000000);
Don't use that int variable, instead declare new bool var to check if you should continue. Also you cannot store string in char variable. You can store them in char arrays, but for beginners it could be easier to use string objects. You can also store string in std::string object and then check it in do-while loop, without using bool variables. Last advise, you should use 'a' for chars, but "abc" for string 'cuz it adds null character at the end of string.