C Language | 10 Minute‐Test 13


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>

    void main()

    {

        int k = 4;

        float k = 4;

        printf("%d", k)

    }

 

A.
Compile time error
B.
4
C.
4.0000000
D.
4.4

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Since the variable k is defined both as integer and as float, it results in an error.

2.

What is the output of this C code?

    #include <stdio.h>

    int main()

    {

        int ary[2][3];

        foo(ary);

    }

    void foo(int (*ary)[3])

    {

        int i = 10, j = 2, k;

        ary[0] = &i;

        ary[1] = &j;

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

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

    }

 

A.
Compile time error
B.
10 2
C.
Undefined behaviour
D.
segmentation fault/code crash

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

3.

What will be the data type of the result of the following operation? (float)a * (int)b / (long)c * (double)d

A.
int
B.
long
C.
float
D.
double

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

4.

Which of the following operation is not possible in a register variable?

A.
Reading the value into a register variable
B.
Copy the value from a memory variable
C.
Global declaration of register variable
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

5.

What is the output of this C code?

    #include <stdio.h>

    void main()

    {

        int x;

    }

 


here x is

A.
automatic variable
B.
static variable
C.
register variable
D.
global variable.

Your Answer: Option (Not Answered)

Correct Answer: Option A

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 = (int*)malloc(sizeof(int));

        *j = 10;

        return j;

    }

 

A.
10
B.
Segmentation fault/runtime crash since pointer to local variable is returned
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 double x;

        int x;

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

    }

 

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

8.

Which of the following is not a valid variable name declaration?

A.
float PI = 3.14;
B.
double PI = 3.14;
C.
int PI = 3.14;
D.
#define PI 3.14

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

#define PI 3.14 is a macro preprocessor, it is a textual substitution.

9.

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

    #include <stdio.h>

    int main()

    {

        int i = 0;

        do {

            i++;

            printf("in while loop\n");

        } while (i < 3);

    }

 

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

10.

What is the output of this C code?

    #include <stdio.h>

    void main()

    {

        int b = 6;

        int c = 7;

        int a = ++b + c--;

        printf("%d", a);

    }

 

A.
Run time error
B.
15
C.
13
D.
14
Submit your test now to view the Results and Statistics with answer explanation.