C program to calculate the Sum of a series like 1+2+3+4+.....+N

#include <stdio.h>
int main ()
{
int sum, n, num;
scanf("%d",&num);
sum=0;
for ( n=1 ;  n<= num ;    n++)
sum=sum+n;
printf("Result is %d", sum);
}

Comments

Popular posts from this blog

C program to verify a number is positive or not using else if.

C program for making pyramid containing N rows

C program for finding factors