Computer Science, asked by parasdhyani92, 6 months ago

Write a program that calculates the sum of first 100 natural numbers

and print their sum​

Answers

Answered by ABHIRAMA18092007
0

IAM WRITING THIS IN PYTHON

CODE :

n=int(input("Enter a number: "))

sum1 = 0

sum1 = 0while (n > 0):

sum1 = 0while (n > 0): sum1=sum1+n

sum1 = 0while (n > 0): sum1=sum1+n n=n-1

sum1 = 0while (n > 0): sum1=sum1+n n=n-1print("The sum of first n natural numbers is",sum1)

OUTPUT :

(when you run it it asks "Enter a number: " if you enter 100 then it replies "The sum of first n natural numbers is 5050" you can enter any number.

Similar questions