Given the following code and assuming that the file accounts

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;

Solution

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;

   }

 Given the following code and assuming that the file \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site