Count positives and calculate their average from 5 inputs
Count positives and calculate their average from 5 inputs
Write a C program that reads 5 numbers, counts the number of positive numbers, and prints out the average of all positive values.
Pictorial Presentation:

C Code:
Sample Output:
Input the first number: 5 Input the second number: 8 Input the third number: 10 Input the fourth number: -5 Input the fifth number: 25 Number of positive numbers: 4 Average value of the said positive numbers: 12.00
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C program to count negative numbers and calculate their average from five inputs.
- Write a C program to calculate the average of numbers that are above a specified threshold from a set of inputs.
- Write a C program to count and calculate the average of even numbers from a series of five integers.
- Write a C program to count numbers meeting two conditions (e.g., positive and even) and then compute their average.
C Programming Code Editor:
Previous: Write a C program that read 5 numbers and counts the number of positive numbers and negative numbers.
Next: Write a C program that read 5 numbers and sum of all odd values between them.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.