Write a loop that reads positive integers from standard input, printing out those values that are greater than 100, and that terminates when it reads an integer that is not positive. The values should be separated by single blank spaces. Declare any variables that are needed.

2
Write a loop that reads positive integers from standard input, printing out those values that are greater than 100, and that terminates when it reads an integer that is not positive. The values should be separated by single blank spaces. Declare any variables that are needed.

LANGUAGE: C++

CHALLENGE:

Write a loop that reads positive integers from standard input, printing out those values that are greater than 100, and that terminates when it reads an integer that is not positive. The values should be separated by single blank spaces. Declare any variables that are needed.

SOLUTION:


int num;
do{
    cin >> num;
    if (num > 100)
        cout << num << " ";
}
while (num>0);

2 comments

  • Rodney says:

    If this answer was not helpful, please share why it was not helpful and maybe someone else can help the answer. Also, if you know a different of doing it, please share as well.

  • Michael says:

    Have a similar problem like this. Question down bellow:

    Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. After the loop terminates, it prints out the sum of all the even integers read and the sum of all the odd integers read (The two sums are separated by a space). Declare any variables that are needed.

Add comment