Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int count=0,p=0,n=0;
- void nzero()
- {
- count++;
- }
- void positive()
- {
- p++;
- }
- void negative()
- {
- n++;
- }
- int main()
- {
- int num, choice = 1;
- do
- {
- printf("Enter a number.");
- scanf("%d",&num);
- if(num!=0)
- {
- nzero();
- if(num>0)
- positive();
- else
- negative();
- }
- printf("Do you want to enter more? 1.Yes 2.No: ");
- scanf("%d",&choice);
- } while (choice!=2);
- printf("\nNumber of non-zero numbers: %d\n",count);
- printf("Number of positive numbers: %d\n",p);
- printf("Number of negative numbers: %d\n",n);
- return 0;
- }
- //Output
- //Enter a number.-2
- //Do you want to enter more? 1.Yes 2.No: 1
- //Enter a number.0
- //Do you want to enter more? 1.Yes 2.No: 1
- //Enter a number.34
- //Do you want to enter more? 1.Yes 2.No: 2
- //Number of non-zero numbers: 2
- //Number of positive numbers: 1
- //Number of negative numbers: 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement