Question

Calculate sum of First 10 Natural Numbers using for loop in C Language.

Updated on May 31, 2025 | By Learnzy Admin | 👁️ Views: 362 students

Solution
✔ Verified

This C program calculates the sum of the first 10 natural numbers using a for loop.

 Natural numbers start from 1 and go on incrementally.

 In this program, a loop runs from 1 to 10, and in each iteration, the current number is added to a sum variable. By the end of the loop, the variable holds the total sum of numbers from 1 to 10.

This example helps beginners understand how loops and accumulators work together to perform repeated addition in C programming.

#include <stdio.h>

int main() {
    int sum = 0;

    for (int i = 1; i <= 10; i++) {
        sum += i;
    }

    printf("Sum = %d\n", sum);
    return 0;
}

Output:--

Sum of first 10 Natural numbers is = 55
Was this solution helpful? 66
Click here to download practice questions on For Loop In C

More Questions on For Loop In C

Question 1

Print the Alphabet (A to Z) using for loop in C Language


View solution
Question 2

Print a Pattern (Right-Angled Triangle) using for loop in C Language


View solution
Question 3

Calculate factorial of a Number (e.g., 5!) using for loop in C language


View solution
Question 4

Print Table of 5 using for loop in C Language.


View solution
Question 5

Print Even Numbers from 2 to 20 using for loop in C Language.


View solution
Question 6

Print Numbers from 1 to 10 using for loop in C Language.


View solution