Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following program contains errors, Rewrite the correct program: /* This prog

ID: 3759031 • Letter: T

Question

The following program contains errors, Rewrite the correct program:

/* This program uses a function to read three integer values and uses  another  function to compute and print their average to two decimal digits i.e. in the form 999.99 */

  #include<stdio.h>

  void readData (int no1, int no2, int no3 ) ;

  int main(void)

   { int n1, n2, n3

   // a function call to the function readData to read the numbers.

   readData(n1, n2, &n3) ;

     //function call to the function to compute and print the average.

   computeAverage(n1, n2, n3);

   return  ;

   }

    int readData (int* no1, int no2, int no3 )

     printf(" Please enter an integer ") ;

      scanf_s("%d",n1) ;

    printf(" Please enter an integer ") ;

    scanf_s("%d",&n2) ;

    printf(" Please enter an integer ") ;

    scanf_s("%d",&n3) ;

    }

  

  void computeAverage(int no1, int no2, int no3) ;

  { float average ;

   sum = no1 + no2 + no3 ;

    average = sum / 3 ;

     printf(" The numbers are: %d , %d ",no1, no2, no3);

    printf(" average is: %f", average ) ;

  }

Explanation / Answer

Answer :

#include<stdio.h>

void readData (int no1, int no2, int no3 ) ;
void computeAverage (int no1, int no2, int no3 ) ;

int main(void)
{ int n1, n2, n3;
// a function call to the function readData to read the numbers.
readData(n1, n2, n3) ;

//function call to the function to compute and print the average.
computeAverage(n1, n2, n3);
return ;
}

void readData (int no1, int no2, int no3 ){
printf(" Please enter an integer ") ;
scanf("%d",no1) ;
printf(" Please enter an integer ") ;
scanf("%d",no2) ;
printf(" Please enter an integer ") ;
scanf("%d",no3) ;
}
  
void computeAverage(int no1, int no2, int no3)
{ float average ;
int sum;
sum = no1 + no2 + no3 ;
average = sum / 3 ;
printf(" The numbers are: %d , %d %d ",no1, no2, no3);
printf(" average is: %f", average ) ;
}