---------------------------------------------------------------------------------------------
Previous Page
---------------------------------------------------------------------------------------------
11.
Find the output of the following program?
#include
int main()
{
int a = 1;
switch (a)
case 1:
printf("%d", a);
case 2:
printf("%d", a);
case 3:
printf("%d", a);
default:
printf("%d", a);
}
A. No error, output is 1111
B.No error, output is 1
C. Compile time error, no break statements
D. Compile time error, case label outside switch statement
Answer: D
------------------------------------------------------------------------------------------------
12.
Find the output?
#include
int main()
{
int a = 1;
switch (a)
{
case a:
printf("Case A ");
default:
printf("Default");
}
}
A. Output: Case A
B. Output: Default
C. Output: Case A Default
D. Compile time error
Answer: D
-----------------------------------------------------------------------------------
13.
Find the output?
#include
switch (ch)
{
case 'a':
case 'A':
printf("true");
}
A. if (ch == ‘a’ && ch == ‘A’) printf(“true”);
B. if (ch == ‘a’)
if (ch == ‘a’) printf(“true”);
C. if (ch == ‘a’ || ch == ‘A’) printf(“true”);
D. none of the mentioned
Answer: C
----------------------------------------------------------------------------------------
First Page Previous Page Home
----------------------------------------------------------------------------------------
More Imp Topics:
Data Types
Operators
Pointers
Array
Preprocessor
Structures
Control Structures
Switch Case
Previous Page
---------------------------------------------------------------------------------------------
11.
Find the output of the following program?
#include
int main()
{
int a = 1;
switch (a)
case 1:
printf("%d", a);
case 2:
printf("%d", a);
case 3:
printf("%d", a);
default:
printf("%d", a);
}
A. No error, output is 1111
B.No error, output is 1
C. Compile time error, no break statements
D. Compile time error, case label outside switch statement
Answer: D
------------------------------------------------------------------------------------------------
12.
Find the output?
#include
int main()
{
int a = 1;
switch (a)
{
case a:
printf("Case A ");
default:
printf("Default");
}
}
A. Output: Case A
B. Output: Default
C. Output: Case A Default
D. Compile time error
Answer: D
-----------------------------------------------------------------------------------
13.
Find the output?
#include
switch (ch)
{
case 'a':
case 'A':
printf("true");
}
A. if (ch == ‘a’ && ch == ‘A’) printf(“true”);
B. if (ch == ‘a’)
if (ch == ‘a’) printf(“true”);
C. if (ch == ‘a’ || ch == ‘A’) printf(“true”);
D. none of the mentioned
Answer: C
----------------------------------------------------------------------------------------
First Page Previous Page Home
----------------------------------------------------------------------------------------
More Imp Topics:
Data Types
Operators
Pointers
Array
Preprocessor
Structures
Control Structures
Switch Case