C Programming Related Problem 07
Write down a C program Code which shows the summation of nth number of series ---
1 + 2 + 3 + ……………+ n
Following Coding(Using while loop)
#include<stdio.h>
int main ()
{
int i = 0, n, sum =0;
printf("Enter
the Number :");
scanf("%d", &n);
while(i <= n)
{
sum = sum + i;
i++;
}
printf("%d", sum);
return 0;
}
Comments
Post a Comment