C++ Write a program that will ask the user to input n positive numbers. The program will terminate if one of those number is not positive. please respond quickly and clearly, thank you!
The code in c++ is given below.
#include<bits/stdc++.h>
using namespace std;
int main()
{
cout<<"Enter n positive
numbers"<<endl;
int number;
while(1)
{
cout<<"Enter a number:
";
cin>>number;
if(number<=0)
{
cout<<"The number you enter is not
positive."<<endl;
break;
}
}
}
The screenshot of the running code and output is given
below.
If the answer helped please upvote it means a lot. For any query
please comment.
Get Answers For Free
Most questions answered within 1 hours.