To display Average of odd numbers bellow a range using C programming
just copy the bellow code and paste it to your TurboC software. And then run the program.
void main()
{
int r,i,c,t;
float a;
clrscr();
printf("Enter the range : ");
scanf("%d",&r);
i = 1;
c = 0;
t = 0;
while (i<=r)
{
if (i%2!=0)
{
t=t+i;
c++;
}
i++;
}
a=t/c;
printf("\n The average of odd numbers bellow %d is : %f",r,a);
getch();
}
0 comments:
Post a Comment