C Language | 10 Minute‐Test 1


Instruction

  • Total number of questions : 10.
  • Time alloted : 10 minutes.
  • Each question carry 1 mark.
  • No Negative marks
  • DO NOT refresh the page.
  • All the best :-).

1.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       char *p[1] = {"hello"};

       printf("%s", (p)[0]);

       return 0;

   }

 

A.
Compile time error
B.
Undefined behaviour
C.
hello
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

2.

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;

       }

   }

 

A.
yes no
B.
yes
C.
no
D.
Compile time error

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

3.

What is the output of this C code?

#include <stdio.h>

   void main()

   {

       int a = -5;

       int k = (a++, ++a);

       printf("%d\n", k);

   }

 

A.
-3
B.
-5
C.
4
D.
Undefined

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

4.

The output of the code below is

#include <stdio.h>

   int *m();

   void main()

   {

       int k = m();

       printf("%d", k);

   }

   int *m()

   {

       int a[2] = {5, 8};

       return a;

   }

 

A.
5
B.
8
C.
Nothing
D.
Varies

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

5.

Comment on the output of this C code?

#include <stdio.h>

   int main()

   {

       float f1 = 0.1;

       if (f1 == 0.1)

           printf("equal\n");

       else

           printf("not equal\n");

   }

 

A.
equal
B.
not equal
C.
Output depends on compiler
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

6.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       int x = 2, y = 2;

       float f = y + x /= x / y;

       printf("%d %f\n", x, f);

       return 0;

   }

 

A.
2 4.000000
B.
Compile time error
C.
2 3.500000
D.
Undefined behaviour

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

7.

What is the output of the code given below?

#include <stdio.h>

   int main()

   {

       printf("%d ", 1);

       goto l1;

       printf("%d ", 2);

       l1:goto l2;

       printf("%d ", 3);

       l2:printf("%d ", 4);

  }

 

A.
1 4
B.
Compilation error
C.
1 2 4
D.
1 3 4

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

8.

If the file name is enclosed in double quotation marks

A.
The preprocessor treats it as a user-defined file
B.
The preprocessor treats it as a system-defined file
C.
Both a & b
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

9.

What is the output of this C code?

#include <stdio.h>

   void main()

   {

       char *s = "hello";

       char *p = s * 3;

       printf("%c\t%c", *p, s[1]);

   }

 

A.
h e
B.
l e
C.
Compile time error
D.
l h

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

10.

enum types are processed by

A.
Compiler
B.
Preprocessor
C.
Linker
D.
Assembler
Submit your test now to view the Results and Statistics with answer explanation.