Computer Science, asked by LeonardEuler, 1 year ago

Hello !!

Create a C-language program that calculates the arithmetic average of the first 50 natural numbers.


Thank you !​

Answers

Answered by Anonymous
2

Explanation:

see the attachment!!!!!

thank you!!!

Attachments:
Answered by Anonymous
0

Answer:

Allows a user to enter the number (n) he wishes to calculate the sum and average. The program accepts user input using the input function.

Next, run loop till the entered number using the for loop and range() function.

Next, calculate the sum using a sum = sum + current number formula.

At last, after the loop ends, calculate the average using average = sum / n. n is a number entered by the user.

Python Program to calculate the Sum

n = input("Enter Number to calculate sum")

n = int (n)

average = 0

sum = 0

for num in range(0, n+1, 1):

sum = sum+num

print("SUM of first ", n, "numbers is: ", sum )

Output: Run Online

Enter Number to calculate sum 5

Sum of first 5 number is: 15

Similar questions