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
  • This is a Java program Write a program that reads an unspecified number of integers, determines...

    This is a Java program Write a program that reads an unspecified number of integers, determines home many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number to 2 decimal places. System.out.println(countPositive); System.out.println(countNegative); System.out.println(total); System.out.printf("%.2f",total * 1.0 / count); Assume inputs are always integer [-912985158, 912985158] and ends with 0. Input 1 2 -1 3...

  • (Count positive and negative numbers and compute the average of numbers) Write a program that reads...

    (Count positive and negative numbers and compute the average of numbers) Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number. If you entire input is 0, display 'No numbers are entered except 0.' *So I think my code is looping because the...

  • Please write a java program that inputs positive numbers using a while loop until a negative...

    Please write a java program that inputs positive numbers using a while loop until a negative number is input and finds the sum of the numbers input

  • Java programming 1. Write a program that reads an unspecified number of integers, determines how many...

    Java programming 1. Write a program that reads an unspecified number of integers, determines how many positive and negative value have been read, and computes the total and average of the input values (not counting zeros. Your program ends with the input 0. Display the average as a floating point number Here are sample runs: (red indicates a user input) Enter an integer, the input ends if it is 0: 1 2 -1 3 0 The number of positives is...

  • Need help figuring this out Write a program that reads in a sequence of numbers (doubles)...

    Need help figuring this out Write a program that reads in a sequence of numbers (doubles) from standard input until 0 is read, and stores them in an array, This part is done using iteration (loop). You may assume that the maximum size of the array will not be more than 100. Your program computes the maximum number stored in the array, the count of negative numbers, and computes the sum of positive numbers, using recursion. You need to have...

  • write a complete little minion program to inputs numbers until a zero is input. the program...

    write a complete little minion program to inputs numbers until a zero is input. the program determines and prints the largest and the sum

  • using C++ Write a full program (starting from #include) that takes as input the number of...

    using C++ Write a full program (starting from #include) that takes as input the number of seconds after midnight. It then displays the time in hours:minutes:seconds format. Assume the time is displayed in military time, e.g. 06:06:06 or 23:05:57. Note the placement of the zeros for numbers less than 10, which your program should properly display. Your program should show output as in the example below. Enter number of seconds after midnight: 3601

  • Only used main method please. (Count positive and negative numbers and compute the average, of numbers)...

    Only used main method please. (Count positive and negative numbers and compute the average, of numbers) Write a program that reads an unspecified number of integers , determines how many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number. Display the total as a floating-point number. Display the lowest number in the list. Display the...

  • Using basic c++ 2. Count the positive and negative numbers using ***while loop*** • Write a...

    Using basic c++ 2. Count the positive and negative numbers using ***while loop*** • Write a program that reads unspecified number of integers , determines how many negative and positive values have been read. Also calculate total and average. Your program will end with input 0. • Output Enter an integer, the input ends if it is 0: 25 34 -89 72 -35 -67 21 48 0 The number of positives is 5 The number of negatives is 3 The...

  • Question text Find four problems with this program: ------------------------------------------- using namespace std; // this program inputs...

    Question text Find four problems with this program: ------------------------------------------- using namespace std; // this program inputs three integers, determines if negative, positive, or zero int main() { cout << "Enter an integer" << endl; cin >> input;    if (input < 0); cout << "The number is negative."  endl; else if (input > 0) cout << "The number is positive" << endl; else cout << "The number is zero" << endl;    return 0; } programm c++ please and thank you

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