I have been trying to add two conditions to a while loop - please see my code below, for a simple program which adds 2 numbers between 1 and 20.
How do I add the two conditions correctly - ie only repeat the loop when a and b are not in the range of 1-20? My code gives an incorrect result. Replacing a ' for the ; in the condition bracket doesn't work.
//Program which adds to numbers input by user
#include <iostream>
usingnamespace std;
int main()
{
int a=0, b=0, result;
cout << "Program which adds to numbers between 1 and 20 input by user.\n\n";
while (a<1 || a>20; b<1 || b>20)
{
cout << "Inpute first number: \na = ";
cin >> a;
cout << "Inpute second number: \nb = ";
cin >> b;
}
result = a + b;
cout << "Result is: " << result << endl;
system ("pause");
return 0;
}