source file name: While3.C
#include<stdio.h>
int main()
{
int n;
int sum=0;
//clrscr();
n=1; // start
while(n<=100) // end
{
sum=sum+n;
n++; // interval
}
printf("\n sum: %d ",sum); // body
//getch();
return 0;
}
output:
sum: 5050
source file name: While3.C
#include<stdio.h>
int main()
{
int n;
int sum=0;
//clrscr();
n=1; // start
while(n<=100) // end
{
sum=sum+n;
n++; // interval
}
printf("\n sum: %d ",sum); // body
//getch();
return 0;
}
output:
sum: 5050
0 Comments
Post a Comment