counter

Free Hit Counter

C program to print sum of first 50 natural numbers

Q:program to print total of 1 to 50

#include
#include
void main()
{
int i,sum=0;
clrscr();


for(i=0;i<=50;i++)
{
sum=sum+i;
}
printf("sum=%d ",sum);
getch();
}

1 comment:

Unknown said...

i have an array of 100 elements and i have to calculate first 10 numbers average each time.
Give me code of it

Post a Comment