C Language | 10 Minute‐Test 12


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.

Which of the following is not a pointer declaration?

A.
char a[10];
B.
char a[] = {'1', '2', '3', '4'};
C.
char *str;
D.
char a;

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Array declarations are pointer declarations.

2.

What is the output of this C code?

    #include <stdio.h>

    int main()

    {

        int ary[2][3];

        foo(ary);

    }

    void foo(int *ary[])

    {

        int i = 10, j = 2, k;

        ary[0] = &i;

        ary[1] = &j;

        *ary[0] = 2;

        for (k = 0;k < 2; k++)

        printf("%d\n", *ary[k]);

    }

 

A.
2 2
B.
Undefined behaviour
C.
Compiler error
D.
10 2

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

3.

Which type conversion is NOT accepted?

A.
From char to int
B.
From float to char pointer
C.
From negative int to char
D.
From double to char

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Conversion of a float to pointer type is not allowed.

4.

Which among the following is the correct syntax to declare a static variable register?

A.
static register a;
B.
register static a;
C.
Both (a) and (b)
D.
We cannot use static and register together.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

5.

Automatic variables are allocated memory in

A.
heap
B.
Data segment
C.
Code segment
D.
stack.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

6.

What is the output of this C code?

    #include <stdio.h>

    int main()

    {

        int i = 10;

        void *p = &i;

        printf("%f\n", *(float*)p);

        return 0;

    }

 

A.
Compile time error
B.
Undefined behaviour
C.
10
D.
0.000000

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

7.

What is the output of this C code?

    #include <stdio.h>

    static int x;

    void main()

    {

        int x;

        printf("x is %d", x);

    }

 

A.
0
B.
Junkvalue
C.
Run time error
D.
Nothing

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

8.

Which is valid C expression?

A.
int my_num = 100,000;
B.
int my_num = 100000;
C.
int my num = 1000;
D.
int $my_num = 10000;

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

space, comma and $ cannot be used in a variable name.

9.

What is the output of this C code?

    #include <stdio.h>

    int main()

    {

        int i = 0;

        do {

            i++;

            printf("In while loop\n");

        } while (i < 3);

    }

 

A.
In while loop In while loop In while loop
B.
In while loop In while loop
C.
Depends on the compiler
D.
Compile time error

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

10.

What is the output of this C code?

    #include <stdio.h>

    void main()

    {

        int a = 5 * 3 % 6 - 8 + 3;

        printf("%d", a);

    }

 

A.
10
B.
2
C.
-2
D.
-3
Submit your test now to view the Results and Statistics with answer explanation.