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: 3574338 • Letter: T

Question

The following code has 5 different errors. The errors can be any of three types, i.e., compile (compile-time and syntax errors), execution (run-time errors), or logic errors. There may be more than one error of the same type. A line may incorrect line(s) and the same line(s) as corrected. Assume that the proper required header files have been included./* Exchange the values in two memory locations */int main() {int a, b, c/*Prompt the user to enter the numbers */printf ("Enter the values of a and b"); scanf ("%f %f", a, b);/* Exchange the values */a = b; c = a; b = c;/*Display the values of variables a and b */printf ("the values of a and b are: ", a, b);} Write the line(s) containing the 1^st error and correct the line(s). Write the line(s) containing the 2^nd 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). Write the line(s) containing the 5^th error and correct the line(s).

Explanation / Answer

1)incorrect Line
   int a,b,c
   ERROR: Declaration syntax error in function main
Correct Line
   int a,b,c;


2) incorrect Line
   scanf("%f%f", a, b);
   ERROR: Possible use of 'a' before definition in function main
Correct Line
   scanf("%d%f", &a, b);


3) incorrect Line
   scanf("%f%f", a, b);
   ERROR: Possible use of 'b' before definition in function main
Correct Line
   scanf("%d%d", &a, &b);

4) incorrect Line
   a=b;
   c=a;
   b=c;
   ERROR: Logic Error
Correct Line
   c=a;
   a=b;
   b=c;


5) incorrect Line
   printf(" the values of a and b are: ", a,b);
   ERROR: Syntax Error
Correct Line  
   printf(" the values of a and b are: %d%d", a,b);      

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