Answer to Question #286974 in C++ for Ace

Question #286974

Create a C++ program that will accept input of any number then press 0 to stop. Count and display the positive and negative numbers.


1
Expert's answer
2022-01-12T10:57:28-0500
#include<iostream>
using namespace std;
int main()
{
    int pos=0, neg=0, i;
    cout<<"Enter numbers : ";
    cin>>i;
    while(i != 0)
    {
        if(i > 0)
        {
            pos++;
            cin>>i;
        }
        else
        {
            neg++;
            cin>>i;
        }
    }    
    cout<<"\nFrequency of Positive Numbers: "<<pos;
    cout<<"\nFrequency of Negative Numbers: "<<neg;
    cout<<endl;
    return 0;
}

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