printing sum of positive , negative and zeros without using arrays

#include<iostream>
using namespace std;
int positive=0,negative=0,zero=0,number;
char choice='y';
int main(){
cout<<"enter numbers "<<endl;
int x=0;
while(choice=='y'){

x++;
cout<<x<<" = ";
cin>>number;
if(number>0){
positive+=1;
}
if(number<0){
negative+=1;
}
if(number==0){
zero+=1;
}

cout<<"press y to continue =  ";
cin>>choice;
}
cout<<" the number of positive numbers = "<<positive<<endl;
cout<<" the number of negative numbers = "<<negative<<endl;
cout<<" the number of zeros  = "<<zero<<endl;
}
Previous
Next Post »

Comments:

Disqus Shortname