//C program to demonstrate
//Sum of Natural Numbers
//using while loop
#include <stdio.h>
int main()
{
int i,s=0;
int n=10;
i=1;
//while loop executes
//the statements until the
//condition is false
while(i<=n){
//adding natural numbers
//upto given number n
s+=i;
i++;
}
//printing the result
printf("Sum= %d",s);
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: