C Language | 10 Minute‐Test 2


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 = {"hello", "hi", "bye"};

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

       return 0;

   }

 

A.
Compile time error
B.
Undefined behaviour
C.
hello
D.
Address of hello

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

2.

What is the output of this C code?

#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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

3.

What is the output of this C code?

#include <stdio.h>

   void main()

   {

       int a = 5, b = -7, c = 0, d;

       d = ++a && ++b || ++c;

       printf("\n%d%d%d%d", a, b, c, d);

   }

 

A.
6 -6 0 0
B.
6 -5 0 1
C.
-6 -6 0 1
D.
6 -6 0 1

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

4.

The output of the code below is

#include <stdio.h>

   void m(int k)

   {

       printf("hi");

   }

   void m(double k)

   {

       printf("hello");

   }

   void main()

   {

       m(3);

   }

 

A.
hi
B.
hello
C.
Compile time error
D.
Nothing

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

5.

Comment on the output of this C code?

#include <stdio.h>

   int main()

   {

       float f1 = 0.1;

       if (f1 == 0.1f)

           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 A

Explanation:

0.1f results in 0.1 to be stored in floating point representations.

6.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       int x = 1, y = 2;

       if (x && y == 1)

           printf("true\n");

       else

           printf("false\n");

   }

 

A.
true
B.
false
C.
Compile time error
D.
Undefined behaviour

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

7.

What is the output of code given below?

#include <stdio.h>

   int main()

   {

       printf("%d ", 1);

       l1:l2:

       printf("%d ", 2);

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

   }

 

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

8.

If the file name is enclosed in angle brackets

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 B

Explanation:

None.

9.

What is the output of this C code?

#include <stdio.h>

   void main()

   {

       char *s= "hello";

       char *p = s + 2;

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

   }

 

A.
l e
B.
h e
C.
l l
D.
h l

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

10.

What is the output of this C code?

    #include <stdio.h>

    int main()

    {

        printf("pooripadhai\rclass\n");

        return 0;

    }

 

A.
pooripadhaiclass
B.
pooripadhai
class
C.
classundry
D.
pooripadhai

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

r is carriage return and moves the cursor back. sanfo is replaced by class.


Submit your test now to view the Results and Statistics with answer explanation.