C Language | 10 Minute‐Test 7


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 declaration are illegal?

A.
int a[][] = {{1, 2, 3}, {2, 3, 4, 5}};
B.
int *a[] = {{1, 2, 3}, {2, 3, 4, 5}};
C.
int a[4][4] = {{1, 2, 3}, {2, 3, 4, 5}};
D.
Both (a) and (b).

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

2.

Comment on the output of this C code?

#include <stdio.h>

   switch (ch)

   {

   case 'a':

   case 'A':

       printf("true");

   }

 

A.
if (ch == ‘a’ && ch == ‘A’) printf(“true”);
B.
if (ch == ‘a’)
if (ch == ‘a’) printf(“true”);
C.
if (ch == ‘a’ || ch == ‘A’) printf(“true”);
D.
Both a and b

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 y = 0;

       if (1 |(y = 1))

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

       else

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

 

   }

 

A.
y is 1
B.
1
C.
Run time error
D.
Undefined

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

4.

functions can return enumeration constants in c?

A.
true
B.
false
C.
Depends on the compiler
D.
depends on the standard

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

5.

Which of the datatypes have size that is variable?

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Since the size of the structure depends on its fields, it has a variable size.

6.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       int x = 2, y = 0;

       int z = x && y = 1;

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

   }

 

A.
1
B.
0
C.
Compile time error
D.
2

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

7.

The output of the code below is

#include <stdio.h>

   void main()

   {

       int i = 0;

       if (i == 0)

       {

           goto label;

       }

       label: printf("Hello");

   }

 

A.
Nothing
B.
Error
C.
Infinite Hello
D.
Hello

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

8.

Which of the following names for files not accepted?

A.
header.h.h
B.
123header.h
C.
None of the mentioned
D.
_head_er.h

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

All file names are accepted as for the execution to occur. There are no constraints on giving file names for inclusion.

9.

What is the output of this C code?

    #include <stdio.h>

    int main()

    {

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

        int *ptr  =  &a[2];

        float n = 1;

        ptr = ptr + n;

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

    }

 

A.
4
B.
3
C.
Compile time error
D.
Undefined behaviour

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

10.

Comment on the output of this C code?

    #include <stdio.h>

    void main()

    {

        int const k = 5;

        k++;

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

    }

 

A.
k is 6
B.
Error due to const succeeding int
C.
Error, because a constant variable can be changed only twice
D.
Error, because a constant variable cannot be changed

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Constant variable has to be declared and defined at the same time. Trying to change it results in an error.


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