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