Find out the output
#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;
}
}
a) yes no
b) yes
c) no
d) Compile time error
Answer:d
Find out the output
#include <stdio.h>
#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
Find out the output
#include <stdio.h>
int main()
{
switch (printf("Do"))
{
case 1:
printf("First\n");
break;
case 2:
printf("Second\n");
break;
default:
printf("Default\n");
break;
}
}
a) Do
b) DoFirst
c) DoSecond
d) DoDefault
Answer:c
Find out the output
#include <stdio.h>
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
Find out the output
#include <stdio.h>
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
Find out the output
#include <stdio.h>
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) Both a and b
View Answer
Answer:c
#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;
}
}
a) yes no
b) yes
c) no
d) Compile time error
Answer:d
Find out the output
#include <stdio.h>
#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
Find out the output
#include <stdio.h>
int main()
{
switch (printf("Do"))
{
case 1:
printf("First\n");
break;
case 2:
printf("Second\n");
break;
default:
printf("Default\n");
break;
}
}
a) Do
b) DoFirst
c) DoSecond
d) DoDefault
Answer:c
Find out the output
#include <stdio.h>
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
Find out the output
#include <stdio.h>
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
Find out the output
#include <stdio.h>
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) Both a and b
View Answer
Answer:c
No comments:
Post a Comment