Entered number is zero, positive or negative
C Program to check entered number is ZERO, POSITIVE or NEGATIVE until user does not want to quit.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int num,zero=0,positive=0,negative=0;
char ch;
do
{
printf("\nEnter the number\t:");
scanf("%d",&num);
if(num==0)
zero++;
else if(num>0)
positive++;
else if(num<0)
negative++;
printf("Do you want to enter another number (y/Y for yes)\t:");
fflush(stdin);
scanf("%c",&ch);
}while(ch == 'y' || ch == 'Y');
printf("\nNumber of Zeroes entered\t\t:%d",zero);
printf("\nNumber of positive numbers entered\t:%d",positive);
printf("\nNumber of negative numbers entered\t:%d",negative);
getch();
}
Output
Enter the number :3
Do you want to enter another number (y/Y for yes) :y
Enter the number :4
Do you want to enter another number (y/Y for yes) :y
Enter the number :0
Do you want to enter another number (y/Y for yes) :y
Enter the number :-4
Do you want to enter another number (y/Y for yes) :y
Enter the number :-5
Do you want to enter another number (y/Y for yes) :y
Enter the number :6
Do you want to enter another number (y/Y for yes) :n
Number of Zeroes entered :1
Number of positive numbers entered :3
Number of negative numbers entered :2