In this easy coded program, you will learn how to find sum of all the numbers till 'n', where n is up to where you want the sum to be calculated.
---------------------------------------------------------------------------
Output
---------------------------------------------------------------------------
Hope you found this 'C Program to Find Sum of All Numbers till 'n'' easy, simple and helpful!
Try to solve more queries by yourself by referring more examples from BEGINC. Here you will get the most easiest code to each and every query. Keep practicing. More programs are coming.
---------------------------------------------------------------------------
Program to Find Sum of Numbers Till 'n'
/*Sum of All Numbers till n*/
|
#include<stdio.h>
|
void main()
|
{
|
int
i, n, sum=0;
|
printf("Enter Number: ");
|
scanf("%d", &n);
|
for(i=1;
i<=n;
i++)
|
{
|
sum=sum+i;
|
}
|
printf("The sum of all the numbers till %d is %d.",
n, sum);
|
}
|
Output
Enter Number: 20
The sum of all the numbers till 20 is 210.
---------------------------------------------------------------------------
Hope you found this 'C Program to Find Sum of All Numbers till 'n'' easy, simple and helpful!
Try to solve more queries by yourself by referring more examples from BEGINC. Here you will get the most easiest code to each and every query. Keep practicing. More programs are coming.

Comments
Post a Comment
Please do not comment any spam links in the comment box.