Advertisement

Program of sum of 1 to n numbers (Upto 32768):


#include<stdio.h>
#include<conio.h>
void main()
{
int i,s,n;
clrscr();
printf("n Input number::");
scanf("%d",&n);
s=0;
for(i=1;i<=n;i++)
s=s+i;
printf("\n result is 1 to %d=%d",n,s);
getch();
}

No comments:

Post a Comment

Please comment bellow. Share your knowledge