Create a C++ program that will accept input of any number then press 0 to stop. Count and display the positive and negative numbers.
#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;
}
Comments
Leave a comment