This is program of while loop in which we are going to display sum of numbers from 1 to n in C Programming.
#include <stdio.h>
int main()
{
int sum = 0;
int i = 1,n;
printf("Enter the number: ");
scanf("%d",&n);
while (i <= n)
{
sum = sum + i;
i++;
}
printf("Sum of natural numbers from 1 to %d : %d",n, sum);
return 0;
}
//......Coded by ARADHANA MISHRA
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP