what will be the output of the following programs. Also (a) explain the output a
ID: 3869918 • Letter: W
Question
what will be the output of the following programs. Also
(a) explain the output and
(b) if an error occurred while executing the given program, analyse the error and
proposed the solution (while presenting present error and your proposed solution side by side.)
Explanation / Answer
Solution:
I'll be explaining each line one by one where the error is present
float a b, c;
there should be a comma between a and b. so the correct syntax is
float a, b, c;
The syntax of scanf_s is wrong
the correct syntax is
scanf_s("%f", &a, &b, 1);
There shouldn't be a colon(:) after if statement
instead of
if(a>b):
it should be like
if(a>b)
same goes for else as well
instead of
else:
it should be
else
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.