//A program to print/display sum of 1 to n natural numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1,n,sum=0;
printf("enter value of 'n'\n");
scanf("%d",&n);
while(k<=n)
{
sum=sum+k;
k++;
}
printf("sum=%d",sum);getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int k=1,n,sum=0;
printf("enter value of 'n'\n");
scanf("%d",&n);
while(k<=n)
{
sum=sum+k;
k++;
}
printf("sum=%d",sum);getch();
}