Saturday, 7 May 2016

Program to print number series in C

Program to print number series in C

Hello friends today we learn about how to write Program to Print Number Series in C. This code is very simple you need to add all number with each other.

Program to print number series in C

In c programming with the help of looping concept you can print any series like below;

Calculate 1 + 2 + 3 + 4 + 5 + ... + n series

Code

void main()
{
int i,num,sum=0;
clrscr();
num=10;
for(i=1;i<=num;i++)
{
sum+=i;
}
printf("Sum: %d",sum);
getch();
}

Output:

55

No comments:

Post a Comment