Question

10) Write a program that inputs five numbers and determines the number of negative numbers input, the number of positive numbers input and the number of zeros input. An easy way to create a counter is given in the example below: int counter 0; initializes the counter counter counter +1;//increments the counter each time is used. Note: Output should read as shown below where # replaces the number of inputs and it is displayed on a table format] (40 pts.) Cudhso Positive numbers : # Negative numbers: # tu Zeros numbers :#
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

int main()
{
int arr[5];//to store 5 numbers
int i=0,counter=0;
printf("enter 5 numbers:\n");
for(i=0;i<5;i++)
scanf("%d",&arr[i]);
//count +ve numbers
for(i=0;i<5;i++)
if(arr[i]>0)
counter=counter+1;
printf("Positive numbers :%d\n",counter);
  
counter=0;
//count -ve numbers
for(i=0;i<5;i++)
if(arr[i]<0)
counter=counter+1;
printf("Negative numbers :%d\n",counter);
  
counter=0;
//count 0's
for(i=0;i<5;i++)
if(arr[i]==0)
counter=counter+1;
printf("Zero numbers :%d\n",counter);
  
return 0;
}

8:41 PM hitesh xC IChegg.com х <D media/25d/2548c446-bl X . + Online C Compiler-onli X CSecure https://www.onlinegdb.com/onli

Add a comment
Know the answer?
Add Answer to:
10) Write a program that inputs five numbers and determines the number of negative numbers input,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT