#include<stdio.h>
#include<conio.h>
void main()
{
int odnum , sum=0; // odnum Stands for Odd Number
do
{
sum=sum+odnum; // It is also written as sum+=odnum
odnum=odnum+2; // It is also written as odnum+=2
}while(odnum<=50);
printf(" Sum=%d\n" , sum);
} /* End of main() */
Output:
Sum=625
0 Response to "C Program: Calculate the Sum of all Odd numbers between 1 to 50 by using do-while Statement"
Post a Comment