Question: a) The variable userChar is a char and encodrdVal is an int. What will encodedVal be for ech userChar value? switch (userChar) { case 'A':

a) The variable userChar is a char and encodrdVal is an int. What will encodedVal be for ech userChar value?

switch (userChar)

{

case 'A':

encodedVal = 1;

break;

case 'B':

encodedVal = 2;

break;

case 'C':

case 'D':

encodedVal = 4;

break;

case 'E':

encodedVal = 5;

break;

case 'F':

encodedVal = 6;

break;

default:

encodedVal = -1;

break;

}

b) If the following fragments were part of a complete program, what would they print without running the code?

1)

int x = 0;

while (++x < 3)

{

printf("%4d", x);

}

2)

int x =100;

while (x++ < 103)

{

printf("%4d ", x);

}

3)

char ch = 's';

while (ch < 'w')

{

printf("%c", ch);

ch++;

}

c) What will the following program print without running the code?

#include

int main (void)

{

int i = 0;

while (i < 3) {

switch (i++) {

case 0: printf ("fat");

case 1: printf ("hat");

case 2: printf ("cat");

defult: printf ("oh no!");

}

putchar (' ');

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!