it seems like it is the basic stuff that bits me.... this one is suppose to be easy, it doesn't go in to the while loop and the program is suppose to go through the while loop.
any suggestions how to fix this?
The Question:
Suppose we want to input and validate three integers in a do..while loop. The variable names are n1, n2 and n3. The requirement is that the sum of the three integers is less than 1000 or that n3 is greater than 100. If this condition does not hold, the loop has to be executed again. Write down a correct condition for the do..while loop.
My Coding:
#include <iostream>
using namespace std;
int main()
{
int n1, n2, n3, sum;
do
{
cout<<"Enter a number:";
cin>>n1;
cout<<"Enter a second Number:";
cin>>n2;
cout<<"Enter a third Number:";
cin>>n3;
sum = n1 + n2 + n3;
//loop if sum is less than 1000 OR n3 is greater than 100
} while ((n3 <= 100) && (sum >= 1000));
return 0;
}
any suggestions how to fix this?
The Question:
Suppose we want to input and validate three integers in a do..while loop. The variable names are n1, n2 and n3. The requirement is that the sum of the three integers is less than 1000 or that n3 is greater than 100. If this condition does not hold, the loop has to be executed again. Write down a correct condition for the do..while loop.
My Coding:
#include <iostream>
using namespace std;
int main()
{
int n1, n2, n3, sum;
do
{
cout<<"Enter a number:";
cin>>n1;
cout<<"Enter a second Number:";
cin>>n2;
cout<<"Enter a third Number:";
cin>>n3;
sum = n1 + n2 + n3;
//loop if sum is less than 1000 OR n3 is greater than 100
} while ((n3 <= 100) && (sum >= 1000));
return 0;
}