Previous Next
0 / 7
Module DEMO-32-58DEMO-C-32

Sum of Numbers

DEMO-C-32 • Programming in C

Browser-only practice

Problem Statement

Write a C program that calculates the sum of all integers from 1 to 20 (inclusive) using a loop.

Your program should output the result in the format: "The sum is: X" where X is the calculated sum.

This exercise helps you practice using loops to perform repetitive calculations.

Constraints

• Use a loop (for, while, or do-while) to calculate the sum • Do not hardcode the result • The program should work without any user input

Input Format

This program takes no input. It should calculate the sum directly.

Output Format

Output a single line in the format: "The sum is: X" where X is the sum of integers from 1 to 20.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
The sum is: 210
Sample test case showing the expected output format. The sum of numbers from 1 to 20 is 210.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings