السابق التالي
0 / 7
الوحدة النمطية DEMO-32-58DEMO-C-32

Sum of Numbers

DEMO-C-32 • Programming in C

Browser-only practice

بيان المشكلة

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.

قيود

• 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

تنسيق الإدخال

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

تنسيق الإخراج

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

حالات اختبار نموذجية

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

العينة رقم 1
عينة ظاهرة
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
إعدادات المحرر