Skip to content

Instantly share code, notes, and snippets.

@jagdish4501
Last active April 9, 2023 12:43
Show Gist options
  • Save jagdish4501/c5efff23474a5bed52e0db811cb48f2a to your computer and use it in GitHub Desktop.
Save jagdish4501/c5efff23474a5bed52e0db811cb48f2a to your computer and use it in GitHub Desktop.
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 i, p = 0, n = 0, o = 0, a;
// p--> positive , n---> negative ,o---> zero ;
int wish; // y=1(yess) , n=0(no)
for (i = 1; i >= 1; i++)
{
printf("enter your wish to enter a number or not(y=1,n=0) =");
scanf("%d", &wish);
if (wish == 1)
{
printf("\nenter a number=");
scanf("%d", &a);
if (a > 0)
{
p = p + 1;
}
else if (a == 0)
{
o = o + 1;
}
else if (a < 0)
{
n = n + 1;
}
}
else if(wish==0)
{
printf(" total number of positive entries=%d \n total nuber of negative entries=%d \n toal number of zero enteries=%d", p, n, o);
break;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment