#include <iostream>
usingnamespace std;
int main()
{
int firstnum, secondnum;
int sum;
cout << "Enter two integers: ";
cin >> firstnum >> secondnum;
cout << endl;
while (firstnum > secondnum)
cout << "The first number must"
<< "be less than the second number.";
secondnum = secondnum * firstnum;
return 0;
}
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int firstnum, secondnum;
int sum; // Are you going to use it?
cout << "Enter two integers: ";
cin >> firstnum >> secondnum;
cout << endl;
// If the first number is higher than
// the second number, then it is true.
// Otherwise, it is false.
// Use enclosing braces {} to validate
// the user input. Then, ask the user
// to input the values again.
while (firstnum > secondnum)
{
cout << "The first number must"
<< "be less than the second number.";
cout << "Enter two integers: ";
cin >> firstnum >> secondnum;
cout << endl;
}
// Do you want to display the result? If yes,
// then use cout.
secondnum = secondnum * firstnum;
return 0;
}
ok, I think I get it now, what you are doing is using the brackets to check if the statement is true. Right? I was under the impression that it had to be a true/false statement or something of the sort.
No. The syntax of while has two forms. There is either one statement after the condition (like you have), or a block of multiple statements within "brackets".
alright, I'm on board now. The line 27 gives the user the chance to enter a correct input and therefore the gives the program the option to be true or false.