C Language | 10 Minute‐Test 14


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.

A variable declared in a function can be used in main

A.
True
B.
False
C.
True if it is declared static
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Since the scope of the variable declared within a function is restricted only within that function, the above statement is false.

2.

What is the output of this C code?

    #include <stdio.h>

    int main()

    {

        foo(ary);

    }

    void foo(int **ary)

    {

        int i = 10, k = 10, j = 2;

        int *ary[2];

        ary[0] = &i;

        ary[1] = &j;

        printf("%d\n", ary[0][1]);

    }

 

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

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

3.

Which of the following type-casting have chances for wrap around?

A.
From int to float
B.
From int to char
C.
From char to short
D.
From char to int

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

4.

Register variables reside in

A.
stack
B.
registers
C.
heap
D.
main memory

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

5.

Automatic variables are initialised to

A.
Zero
B.
Junk value
C.
Nothing
D.
Both a & b

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

6.

What is the output of this C code?

    #include <stdio.h>

    int *f();

    int main()

    {

        int *p = f();

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

    }

    int *f()

    {

        int j = 10;

        return &j;

    }

 

A.
10
B.
Segmentation fault/runtime crash
C.
Compiler error
D.
Undefined behaviour

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

7.

What is the output of this C code?

#include <stdio.h>

void main()

{

static int x;

if (x++ < 2)

main();

}

 

A.
Infinite calls to main
B.
Run time error
C.
Varies
D.
main is called twice

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

8.

What will happen if the below program is executed?

    #include <stdio.h>

    int main()

    {

        int main = 3;

        printf("%d", main);

        return 0;

    }

 

A.
It will cause a compile-time error
B.
It will cause a run-time error
C.
It will run without any error and prints 3
D.
It will experience infinite looping

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

A C program can have same function name and same variable name.

9.

How many times i value is checked in the below code?

    #include <stdio.h>

    int main()

    {

        int i = 0;

        while (i < 3)

            i++;

        printf("In while loop\n");

    }

 

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

10.

What is the output of this C code?

    #include <stdio.h>

    void main(

    {

        double b = 8;

        b++;

        printf("%lf", b);

    }

 

A.
9.000000
B.
9
C.
9.0
D.
Run time error
Submit your test now to view the Results and Statistics with answer explanation.