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.
#include <stdio.h>
int main()
{
int number, positive = 0, negative = 0, zero = 0;
char choice;
do
{
printf("Enter a number :");
scanf("%d", &number);
if (number > 0)
{
positive++;
}
else if (number < 0)
{
negative++;
}
else
{
zero++;
}
printf("Do you want to Continue(y/n)? ");
scanf("%c", &choice);
}while (choice == 'y' || choice == 'Y');
printf("\nPositive Numbers :%d\nNegative Numbers :%d\nZero Numbers :%d",
positive, negative, zero);
return 0;
}
Enter a number :10
Do you want to Continue(y/n)? y
Enter a number :5
Do you want to Continue(y/n)? y
Enter a number :-6
Do you want to Continue(y/n)? y
Enter a number :0
Do you want to Continue(y/n)? y
Enter a number :-4
Do you want to Continue(y/n)? n
Positive Numbers :2
Negative Numbers :2
Zero Numbers :1