Question: This is meant to be done in C programming code. For a number N input by the user, 1. Print the average of all numbers

This is meant to be done in C programming code.

For a number N input by the user,

1. Print the average of all numbers from 1 to N,

2. Print the average of all even numbers from 1 to N, and

3. Print the average of all odd numbers from 1 to N.

4. Print the average of every third number ( e.g., 1, 4, 7, )

The program should not accept a negative number. If the user enters a negative number, it should ask for a new number. Once the program prints output on the console, it should ask the user if s/he is interested in entering another number. If the user enters y or Y the program will continue the execution, but for any other input, the program will terminate.

Hint: Use a for loop to solve this problem.

Example: Enter a positive number: 5

The average of all numbers from 1 to 5 is 3

The average of all even numbers from 1 to 5 is 3

The average of all odd numbers from 1 to 5 is 3

The average of every third number from 1 to 5 is 2.5

Would you like to enter another number? N

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!