The program segment given below using a do …while loop and then determines the average of the given numbers.
#include <stdio.h>
void main()
{
int n,i;
float sum,x,avg;
clrscr();
printf(“How many numbers? “);
scanf(“%d”, &n);
sum = 0.0;
i = 0;
do {
scanf(“%f”, &x);
sum += x;
i++;
}while (i < n);
avg = sum/ n; /* sum is assumed to be of type float */
printf (“The Sum is = %f \n”,sum);
printf (“The Average is = %f \n”,avg);
getch();
}