C Language | 10 Minute‐Test 3


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()

   {

       int i = 0, j = 1;

       int *a[] = {&i, &j};

       printf("%d", (*a)[0]);

       return 0;

   }

 

A.
Compile time error
B.
Undefined behaviour
C.
0
D.
Some garbage value

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

2.

What is the output of this C code?

#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.
DoFirst
B.
Do
C.
DoSecond
D.
DoDefault

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

3.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       int x = 2;

       x = x << 1;

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

   }

 

A.
4
B.
1
C.
Depends on the compiler
D.
Depends on the endianness of the machine

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

4.

What is the default return type if it is not specified in function definition?

A.
void
B.
int
C.
short int
D.
double

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

5.

What is the output of this C code (on a 32-bit machine)?

#include <stdio.h>

   int main()

   {

       int x = 10000;

       double y = 56;

       int *p = &x;

       double *q = &y;

       printf("p and q are %d and %d", sizeof(p), sizeof(q));

       return 0;

   }

 

A.
p and q are 4 and 4
B.
p and q are 4 and 8
C.
Compiler error
D.
p and q are 2 and 8

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Size of any type of pointer is 4 on a 32-bit machine.

6.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       int x = 1, y = 2;

       int z = x & y == 2;

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

   }

 

A.
0
B.
1
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);

       goto l1;

       printf("%d ", 2);

   }

   void foo()

   {

       l1 : printf("3 ", 3);

   }

 

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

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

8.

What is the output of this C code?

#include (stdio.h)

   void main()

   {

       printf("hello");

   }

 

A.
hello
B.
Nothing
C.
compile time error
D.
Depends on compiler

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

:File to be included must be specified either in “” or <>.

9.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       void *p;

       int a[4] = {1, 2, 3, 8};

       p = &a[3];

       int *ptr = &a[2];

       int n = p - ptr;

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

   }

 

A.
1
B.
Compile time error
C.
Segmentation fault
D.
4

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

10.

What is the output of this C code?

    #include <stdio.h>

    int main()

    {

        printf("pooripadhai\r\nclass\n");

        return 0;

    }

 

A.
pooripadhaiclass
B.
classundry
C.
pooripadhai
class
D.
pooripadhai
Submit your test now to view the Results and Statistics with answer explanation.