Answer to Question #189204 in C++ for Skye Jordan

Question #189204

Based on Control Structure Selection and Control Structure Looping, answer the following questions:

Write a program that will ask the user to input n positive numbers. The program will terminate if one of those numbers is not positive. Output :

https://cdn.discordapp.com/attachments/711213157854609461/839150310864846934/unknown.png


1
Expert's answer
2021-05-06T18:45:32-0400
#include <iostream>
using namespace std;

int main()
{
    const int n=100;

    for(int i=0; i<n; i++) {
        int x;
        cout << "Enter a number:";
        cin >> x;
        if (x <= 0) {
            break;
        }
        cout << endl;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS