Write C statements to repeatedly ask the user to enter two i
Write C++ statements to repeatedly ask the user to enter two integers n and m, and print the sum of n and m. If the user enters 0 for both n and m, stop asking. Sample run:
Again, remember that you\'ll need an extra newline after the prompt for the output to match reasonably. Also, since you\'re working with a loop, watch out for the \"Program timed out\" message indicating that your loop never ended.
Solution
#include<iostream>
using namespace std;
int main()
{
int n,m,sum;
while(1) //Looping using a while loop
{
cout<<\"\ \ Enter an integer \'n\': \";
cin>>n;
cout<<\"Enter an integer \'m\' :\";
cin>>m;
sum=n+m; //Execution of sum of n and m and storing
if(sum==0) //if sum equals 0 (i.e.n=0 and m=0) execute if condition
{
cout<<\"Program timed out\";
break;
}
else
cout<<\"Sum of the numbers is : \"<<sum;
}
}
