Hi i just started programming in c++ and im a little confused as to why my program isn't running efficiently. The object of this assignment is the prompt the user for a THREE DIGIT NUMBER and then multiply each integer together (EX. 123, (1 * 2 * 3). I want to know why when i enter a value for "b" that is < 100 or > 1000, my cout message isn't running, it just kicks the user out of the program.
// PART B
int b, c, d, e;
cout << "please enter a 3 digit number: " << endl;
cin >> b;
if (b < 100 && b > 1000)
{
cout << "sorry but thats not the right number" << endl;
}
while (b >= 100 && b < 1000)
{
c = b / 100;
d = (b / 10) % 10;
e = b % 10;
cout << (c * d * e) << endl;
return 0;
}
cout << endl;
return 0;
}
Thank you so much MiiNiPaa, your insight by using the || was great and totally turned my program around!!! and SamuelAdams your code did not run correctly, the parenthesis made no difference in the program outcome.