/* Program to find the sum of natural numbers in C programming langu */
#include<stdio.h>
#include<conio.h>
void main ()
{
int i,n,sum=0;
clrscr();
printf ("\n Enter the value of n ");
scanf ("%d",&n);
for (i=1;i<=n;i++)
{
sum=sum+i;
}
printf ("\n The sum of n natural numbers is %d",sum);
getch();
}
Output
Enter the value of n
10
The sum of n natural numbers is 55
Now the output will be seen as:
Good job
ReplyDelete