Question: Write a simple program based on the use of For and While loop, to calculate the average of numbers. The program should ask the user

Write a simple program based on the use of For and While loop, to calculate the average of numbers. The program should ask the user to enter how many numbers they want to find the average for and to calculate the avenge depending on that.

Write the program twice: once using for loop and once using while loop. If the user will enter zero or a negative number. the program should displays message (Not valid number)

For example if the user wants to find the average of 3 numbers, the output should be:

How many numbers do you want to find the avenge for?

3

Enter the numbers

2

3

1

The average is 2

Step by Step Solution

3.47 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets tackle both variations of the program one using a for lo... View full answer

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 Programming Questions!