--------------------------------------------------------------------------------------------
Previous Page Next Page
--------------------------------------------------------------------------------------------
6.
Find the output?
#include
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;
}
}
A. 1
B. Compile time error
C. 2
D. Run time error
Answer: B
---------------------------------------------------------------------------------------------------
7.
Find the output of the program?
Put input as '2'.
#include
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");
}
}
A. 1
B. hi 2
C. Run time error
D. 2
Answer: D
-----------------------------------------------------------------------------------------------
8.
Find the output of this program?
#include
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;
}
}
A. 1
B. 2
C. 3
D. None
Answer: B
-----------------------------------------------------------------------------------------------
9.
Find the output?
#include
int main()
{
int x = 97;
switch (x)
{
case 'a':
printf("yes ");
break;
case 97:
printf("no\n");
break;
}
}
A. yes
B. yes no
C. Duplicate case value error
D. Character case value error
Answer: C
----------------------------------------------------------------------------------------------
10.
Find the output?
#include
#define max(a) a
int main()
{
int x = 1;
switch (x)
{
case max(2):
printf("yes\n");
case max(1):
printf("no\n");
break;
}
}
A. yes no
B. yes
C. no
D. Compile time error
Answer: C
---------------------------------------------------------------------------------------------
Previous Home Next
---------------------------------------------------------------------------------------------
More Imp Topics:
Data Types
Operators
Pointers
Array
Preprocessor
Structures
Control Structures
Switch Case
Previous Page Next Page
--------------------------------------------------------------------------------------------
6.
Find the output?
#include
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;
}
}
A. 1
B. Compile time error
C. 2
D. Run time error
Answer: B
---------------------------------------------------------------------------------------------------
7.
Find the output of the program?
Put input as '2'.
#include
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");
}
}
A. 1
B. hi 2
C. Run time error
D. 2
Answer: D
-----------------------------------------------------------------------------------------------
8.
Find the output of this program?
#include
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;
}
}
A. 1
B. 2
C. 3
D. None
Answer: B
-----------------------------------------------------------------------------------------------
9.
Find the output?
#include
int main()
{
int x = 97;
switch (x)
{
case 'a':
printf("yes ");
break;
case 97:
printf("no\n");
break;
}
}
A. yes
B. yes no
C. Duplicate case value error
D. Character case value error
Answer: C
----------------------------------------------------------------------------------------------
10.
Find the output?
#include
#define max(a) a
int main()
{
int x = 1;
switch (x)
{
case max(2):
printf("yes\n");
case max(1):
printf("no\n");
break;
}
}
A. yes no
B. yes
C. no
D. Compile time error
Answer: C
---------------------------------------------------------------------------------------------
Previous Home Next
---------------------------------------------------------------------------------------------
More Imp Topics:
Data Types
Operators
Pointers
Array
Preprocessor
Structures
Control Structures
Switch Case