Exercise: Control Instructions

Questions for: Control Instructions

By default, the data type of a constant without a decimal point is int, whereas the one with a decimal point is a double.
A:
Yes
B:
No
C:
D:
Answer: A

6 is int constant.
6.68 is double.
6.68L is long double constant.
6.68f is float constant.

We want to test whether a value lies in the range 2 to 4 or 5 to 7. Can we do this using a switch?
A:
Yes
B:
No
C:
D:
Answer: A
We can do this in following switch statement

switch(a)
{
    case 2:
    case 3:
    case 4:
       /* some statements */
       break;
    case 5:
    case 6:
    case 7:
       /* some statements */
       break;
}
Can we use a switch statement to switch on strings?
A:
Yes
B:
No
C:
D:
Answer: B
The cases in a switch must either have integer constants or constant expressions.
The way the break is used to take control out of switch and continue to take control of the beginning of the switch?
A:
Yes
B:
No
C:
D:
Answer: B
continue can work only with loops and not with switch
A char variable can store either an ASCII character or a Unicode character.
A:
True
B:
False
C:
D:
Answer: A

Yes, we can store either an ASCII character or a Unicode character in a char variable.

Ad Slot (Above Pagination)
Quiz