Question No. 01
Write a program that input numbers from the user until user press “E”. Program should display total number of positive and negative numbers entered.
#include<iostream>
using namespace std;
int main(){
int i=1,m,p=0,n=0;
char e='t';
while(e!='e'){
cout<<"enter number"<<endl;
cin>>m;
if(m>=0){p=p+1;}
if(m<0){n=n+1;}
cout<<"press E TO QUIT"<<endl;
cin>>e;
}
cout<<"positive numbers="<<p<<"\t negative numbers="<<n<<endl;
return 0;}
Comments
Leave a comment