Monday, 31 December 2018

Filled Under:

Find Average Of Odd Numbers Below A Range[c programming examples with output]

C programming examples with output

Find Average Of Odd Numbers Below A Range
Program

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,d;
float f;
clrscr();
printf("Enter the range: ");
scanf("%d",&b);
a=1;c=0;d=0;
while(a<=b)
{
            if(a%2!=0)
      {
d=d+a;
c++;
}
           a++;
}
f=d/c;
printf("\nThe average of odd numbers below %d: %f",b,f);
getch();
}


Output
Enter the range:20
The average of odd numbers below 20: 10.000000


Check others programming by click here:

0 komentar:

Post a Comment