C-programming - Sum of numbers, C program to find sum of numbers

Sum of numbers

This program calculates the sum of first five numerals. A for loop is used for this purpose.


#include<stdio.h>
#include<conio.h>
int main()
{
    int i,sum=0;
    for(i=0; i<=5; i++)
    {
        sum+=i;
        printf("%d\t",i);
}
printf("\nsum is %d",sum);
getch();
}  
 

output


sum is 15


The topic on C-programming - Sum of numbers is posted by - Math

Hope you have enjoyed, C-programming - Sum of numbersThanks for your time

Tech Bluff