Given the following code and assuming that the file \"accounts\" has been opened
ID: 3936387 • Letter: G
Question
Given the following code and assuming that the file "accounts" has been opened for reading, read one integer from the file. Int custId; The following code segment is syntactically correct, but difficult to read. Rewrite the segment using indentation that improves its readability. if (road_stat == 's') if (temp > 0) printf("Roads wet. "); else printf("Roads icy. "); else printf("Roads dry. "); Rewrite the following if statement as an equivalent switch statement. The variable digit is of type int. if (digit == 0) value = 3; else if (digit == 1) value = 3; else if (digit ==2) value = 6; else if (digit == 3) value = 9;Explanation / Answer
Answer :
9Q)
Answer :
if (road_stat == 's')
if (temp > 0)
printf ("Roads wet. ");
else
printf("Roads icy. ");
else
printf("Roads dry. ");
........................
10Q)
Answer :
switch (digit)
{
case 0 :
value = 3;
break;
case 1 :
value = 3;
break;
case 2 :
value = 6;
break;
default :
value = 9;
}
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.