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

The following code has 5 different errors. The errors can be any of three types

ID: 3819792 • Letter: T

Question

The following code has 5 different errors. The errors can be any of three types i.e., (compile and syntax execution (run-time errors), or logic errors. There logic errors. may be more than one error of the same type. A line may contain more than one error. Find and correct the in the code, i.e, write the incorrect line(s) and the same line(s) as corrected. Assume that the proper header files have been included./*Program calculates the average of two integers. */int main(); int{nbr1 nbr2; float avg; printf (" Enter two integers: "); scanf ("%lf %lf ", &nbr1;, &nbr2;); */calculates the average/* avg = nbr1 nbr2/2; printf(" The average is: ", avg); return 0;} Write the line(s) containing the 1^st error and correct the line(s). Write the line(s) containing the 2^rd error and correct the line(s). Write the line(s) containing the 3^rd error and correct the line(s). Write the line(s) containing the 4^th error and correct the line(s).

Explanation / Answer

int main() //first error is ; after main() so removed this
{
   int nbr1,nbr2; //second error is comma ',' .It is not present between nbr1 and nbr2 so i put
   float avg;
   printf(" Enter two integers: ");
   scanf("%d %d",&nb1, &nb2); //Third error nb1 and nb2 are integer so %d use not %lf so i corrected
   /*calculate the average /*

   avg=(nbr1+nbr2)/2; //fourth error is avg value is not calucalted corrected so corrected
   printf(" The average is :%f",avg); //fifth error is %f symbol in printf function
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote