1. What is the output of this C code?
-
#include <stdio.h>
-
void main()
-
{
-
int i = 0;
-
if (i == 0)
-
{
-
printf("Hello");
-
continue;
-
}
-
}
a) Hello is printed infinite times
b) Hello
c) Varies
d) Compile time error
Answer
Answer: d [Reason:] None.
2. What is the output of this C code?
-
#include <stdio.h>
-
void main()
-
{
-
int i = 0;
-
if (i == 0)
-
{
-
printf("Hello");
-
break;
-
}
-
}
a) Hello is printed infinite times
b) Hello
c) Varies
d) Compile time error
Answer
Answer: d [Reason:] None.
3. What is the output of this C code?
-
#include <stdio.h>
-
int main()
-
{
-
int i = 0;
-
do
-
{
-
i++;
-
if (i == 2)
-
continue;
-
printf("In while loop ");
-
} while (i < 2);
-
printf("%dn", i);
-
}
a) In while loop 2
b) In while loop in while loop 3
c) In while loop 3
d) Infinite loop
Answer
Answer: a [Reason:] None.
4. What is the output of this C code?
-
#include <stdio.h>
-
int main()
-
{
-
int i = 0, j = 0;
-
for (i; i < 2; i++){
-
for (j = 0; j < 3; j++){
-
printf("1n");
-
break;
-
}
-
printf("2n");
-
}
-
printf("after loopn");
-
}
a) 1
2
after loop
b) 1
after loop
c) 1
2
1
2
after loop
d) 1
1
2
after loop
Answer
Answer: c [Reason:] None.
5. What is the output of this C code?
-
#include <stdio.h>
-
int main()
-
{
-
int i = 0;
-
while (i < 2)
-
{
-
if (i == 1)
-
break;
-
i++;
-
if (i == 1)
-
continue;
-
printf("In while loopn");
-
}
-
printf("After loopn");
-
}
a) In while loop
After loop
b) After loop
c) In while loop
In while loop
After loop
d) In while loop
Answer
Answer: b [Reason:] None.
6. What is the output of this C code?
-
#include <stdio.h>
-
int main()
-
{
-
int i = 0;
-
char c = 'a';
-
while (i < 2){
-
i++;
-
switch (c) {
-
case 'a':
-
printf("%c ", c);
-
break;
-
break;
-
}
-
}
-
printf("after loopn");
-
}
a) a after loop
b) a a after loop
c) after loop
d) None of the mentioned
Answer
Answer: b [Reason:] None.
7. What is the output of this C code?
-
#include <stdio.h>
-
int main()
-
{
-
printf("before continue ");
-
continue;
-
printf("after continuen");
-
}
a) Before continue after continue
b) Before continue
c) After continue
d) Compile time error
Answer
Answer: d [Reason:] None.