This article is from solution of Let Us C by Yashwant Kanetkar. I also posted many another articles regarding solutions of Let Us C. If you have any problem regarding solution then give comment, I will surely reply your question.
Q. Write a program to enter the numbers till the user wants and at the end it should display the count of positive, negative, and zeros entered.
Ans.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i, pos=0, neg=0, zer=0;
char choice='y';
while(choice=='y')
{
printf("\nenter any number ");
scanf("%d",&i);
if(i>=1)
pos=pos+1;
if(i<=-1)
neg=neg+1;
if(i==0)
zer=zer+1;
printf("\nYou Wanted To Type Another Number(y/n) ");
fflush(stdin);
scanf("%c",&choice);
}
printf("\nCount Of Positive Numbers Entered By User Is %d",pos);
printf("\nCount Of Negative Numbers Entered By User Is %d",neg);
printf("\nCount Of Zeroes Entered by User Is %d",zer);
getch();
}