______________________________________________________________________________________________________________________________________________________________________________________
Program:
#include<stdio.h>
#include<conio.h>
main()
{
int i,s=0,n;
printf("Enter the range: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(i%2!=0)
s=s+i;
}
printf("Sum of all odd numbers below %d is \'%d\'",n,s);
getch();
}
Output:
|
Output screenshot of sum of odd number below given range |
______________________________________________________________________________________________________________________________________________________________________________________
No comments