COUNT HOW MANY NUBERS ARE GREATER THAN ZERO, LESS THAN ZERO

/*PROGRAM TO COUNT HOW MANY NUBERS ENTERED BY USER ARE GREATER THAN ZERO, LESS THAN ZERO AND EQUAL TO ZERO*/
#include<conio.h>
#include<iostream.h>
class count_no
{
int n,num,g,e,l,i;
public:
void process();
};
void count_no::process()
{
cout<<“How many numbers you want to enter: “;
cin>>n;
g=0;
l=0;
e=0;
for(i=1;i<=n;i++)
{
cout<<“Enter “<<i<<” number: “;
cin>>num;
if(num>0)
g++;
else if(num<0)
l++;
else
e++;
}
cout<<“\nNumbers greater than zero are: “<<g<<endl;
cout<<“Numbers less than zero are: “<<l<<endl;
cout<<“Numbers equal to zero are: “<<e<<endl;
}
void main()
{
count_no c1;
clrscr();
c1.process();
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *