Switch Case MCQ Questions and Answers in C Language

Switch Case MCQ Questions and Answers in C Language

Home | C Language | Switch Case

Switch Case MCQ Questions and Answers in C Language: Here learn Switch Case Objective Questions and Answers in C Language. we provide switch case practice questions on c language.

Page: 1/3

1) Which of the following cannot be checked in a switch-case statement?

2) What is the output of this C code(when 1 is entered)?

 #include <stdio.h>
void main()
{
double ch;
printf("enter a value btw 1 to 2:");
scanf("%lf", &ch);
switch (ch)
{
case 1: printf("1");
break;
case 2: printf("2");
break;
}
}

3) What is the output of this C code(When 1 is entered)?

#include <stdio.h>
void main()
{
char *ch;
printf("enter a value btw 1 to 3:");
scanf("%s", ch);
switch (ch)
{
case "1": printf("1");
break;
case "2": printf("2");
break;
}
}

4) What is the output of this C code(When 1 is entered)?

#include <stdio.h>
void main()
{
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch)
{
case 1: printf("1\n");
default: printf("2\n");
}
}

5) What is the output of this C code(When 2 is entered)?

#include <stdio.h>
void main()
{
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch)
{
case 1: printf("1\n");
break;
printf("hi");
default: printf("2\n");
}
}

6) What is the output of this C code(When 1 is entered)?

#include <stdio.h>
void main()
{
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch, ch + 1)
{
case 1: printf("1\n");
break;
case 2: printf("2");
break;
}
}

7) What is the output of this C code?

#include <stdio.h>
int main()
{
int a = 1, b = 1;
switch (a)
{
case a*b: printf("yes ");
case a-b: printf("no\n");
break;
}
}

8) What is the output of this C code?

#include <stdio.h>
int main()
{
int x = 97;
switch (x)
{
case 'a': printf("yes ");
break;
case 97: printf("no\n");
break;
}
}

9) What is the output of this C code?

#include <stdio.h>
int main()
{
float f = 1;
switch (f)
{
case 1.0: printf("yes\n");
break;
default: printf("default\n");
}
}

10) What is the output of this C code?

#include <stdio.h>
const int a = 1, b = 2;
int main()
{
int x = 1;
switch (x)
{
case a: printf("yes ");
case b: printf("no\n");
break;
}
}

Download MCQ PDF