Answer:
Following are the program to this question:
#include<iostream> //defining header file
using namespace std;
int main() //defining main method
{
int sum = 0, num; //defining integer variable
cout << "Enter a number :"; // print message
cin >> num; //input number
sum=sum+num;
while (sum < 200) //defining loop that check sum value is less then 200
{
cin >> num; //input number by user
sum =sum+num; //add values
}
cout << "Sum = " << sum <<" the loop stops"; //print values
return 0;
}
output:
Enter a number :44
66
90
Sum = 200 the loop stops
Step-by-step explanation:
In the given C++ program, the main method is declared, inside the method two integer variable "sum and num" is declared, in which sum variable assign a value, that is 0, and num is used to take input from the user end.
- In the next step, a sum variable adds num variable value and use a while loop that checks value is less than 200.
- In this condition is not true so, inside the loop, it takes value from the user and into the sum variable when its value is above 200, it will exit the loop and prints its total value.