Sunday, 7 January 2018

Average of every third integer between 1 to 100

Q : Write and explain the action of WHILE statement. Develop a program in ‘C’ language to compute the average of every third integer number lying between 1 and 100. Include appropriate documentation.

Solution : 

Read While loop

Program :

void main()
     int a,b,c;

     printf("\n\tAverage of every third integer between 1 to 100 is %d",c/b);

Documentation :

  • Variable a is used for count 1 to 100
  • variable c is sum of every third integer . get by a because a is incremented by 3 in each loop turn.
  • Variable b is used to trace how many third number are in range of 1 to 100.
  • As we know formula of calculating average is sum of value divided by number of element is perform while printing