The following code has 5 different errors. The errors can be any of three types,
ID: 3573636 • 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 contain more than one error in the code, i.e., write the 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 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 3rd error and correct the line(s). Write the line(s) containing the 4^th error and correct the line(s). Write the line containing the 5^th error and correct the line(s).Explanation / Answer
a) First error- syntax error
error- int a,b,c
correct- int a,b,c;
b) Second error- syntax error
error - scanf("%f %f",a,b);
correct- scanf("%d %d",&a,&b);
c)Third error- logical error
error - a=b;
c=a;
b=c;
correct - c=a;
a=b;
b=c;
4)Fourth error - compile time
error - printf("the values of a and b are:",a,b);
correct - printf("the values of a and b are:%d %d",a,b);
5) Fifth Error-runtime
error - no return value
correct - return 0;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.