Decision Making
- Which datatype can accept switch statement?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
None of these
- Comment on the output of the following C code.
#include <stdio.h>
int main()
{
int num = 2;
switch (num)
case 1:
printf("%d", num);
case 2:
printf("%d", num);
case 3:
printf("%d", num);
default:
printf("%d", num);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Compile time error, case label outside switch statement
- Which of the following errors would be reported by the compiler on compiling the program given below?
#include <studio.h>
int main ( )
{
int a = 5;
switch (n)
{
case 1 :
..
case 2 :
..
case 3 + 5 :
..
case a :
..
}
return 0;
}
-
View Hint View Answer Discuss in Forum
Variables cannot be checked using a switch as in case a.
Correct Option: A
Variables cannot be checked using a switch as in case a.
- What will be the output of the following C code?
#include <stdio.h>
#define max(p) p
int main()
{
int n = 1;
switch (n)
{
case max(2):
printf("Right...\n");
case max(1):
printf("Wrong...\n");
break;
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Wrong...
- What will be the output of the following C code?
#include <stdio.h>
const int n = 10, m = 12;
int main()
{
int P = 10;
switch (P)
{
case n:
printf("Yes...");
case m:
printf("No...\n");
break;
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Yes... No...