1.

Write the program to calculate the sum of numbers from 1 to 100.Example: # program to calculate the sum of numbers 1 to 100

Answer»

n = 100

sum = 0

for counter in range (1, n + 1):

sum = sum + counter

print (“Sum of 1 until %d: %d” % (n,sum))

Output:

Sum of 1 until 100: 5050



Discussion

No Comment Found