Advertisement

Sum of 1 to 100 of using “while” loop:


#include<stdio.h>
#include<conio.h>
void main()
{
int s,i;
clrscr();
printf("input values::");
scanf("%d",&s);
i=1;
do
{
s=s+i;
i=i+1;
}while(i<=100);
printf("result=%d",s);
getch();
}

No comments:

Post a Comment

Please comment bellow. Share your knowledge