Write a program to accept 20 numbers from the user

And count how many positive and how many negative and 0 numbers were entered!!
pls

Questions by cguyc

Showing Answers 1 - 3 of 3 Answers

delbin

  • Jul 22nd, 2012
 

Code
  1. #include<stdio.h>

  2.  

  3. main()

  4. {

  5.         int a[20],i;

  6.         int pos,neg,zero;

  7.  

  8.         pos=neg=zero=0;

  9.  

  10.         for(i=0;i<5;i++)

  11.         {

  12.                 scanf("%d",&a[i]);

  13.                 if(a[i]>0)

  14.                         pos++;

  15.                 else if(a[i]<0)

  16.                         neg++;

  17.                 else

  18.                         zero++;

  19.         }

  20.         printf("+:%d -:%d 0:%d

  21. ",pos,neg,zero);

  22.  

  23. }

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions