C Language | 10 Minute‐Test 8


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.

Comment on the output of this C code?

#include <stdio.h>

   void main()

   {

       float x = 0.1;

       printf("%d, ", x);

       printf("%f", x);

   }

 

A.
0.100000, junk value
B.
Junk value, 0.100000
C.
0, 0.100000
D.
0, 0.999999

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

2.

What is the output of this C code?

#include <stdio.h>

   void main()

   {

       int k;

       for (k = -3; k < -5; k++)

           printf("Hello");

   }

 

A.
Hello
B.
Infinite hello
C.
Run time error
D.
Nothing

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

3.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       int y = 1;

       if (y & (y = 2))

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

       else

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

 

   }

 

A.
true 2
B.
false 2
C.
Either option a or option b
D.
true 1

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

4.

What is the output of code given below?

#include <stdio.h>

   enum m{JAN, FEB, MAR};

   enum m foo();

   int main()

   {

       enum m i = foo();

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

   }

   int  foo()

   {

       return JAN;

   }

 

A.
Compile time error
B.
0
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 following is not a valid C variable name?

A.
int number;
B.
float rate;
C.
int variable_count;
D.
int $main;

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Since only underscore and no other special character is allowed in a variable name, it results in an error.

6.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       int x = 2, y = 2;

       int z = x ^ y & 1;

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

   }

 

A.
1
B.
2
C.
0
D.
1 or 2

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

7.

The output of the code below is

#include <stdio.h>

   void main()

   {

       int i = 0, k;

       if (i == 0)

           goto label;

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

           {

               printf("hi\n");

               label: k = printf("%03d", i);

           }

   }

 

A.
0
B.
hi hi hi 0 0 0
C.
0 hi hi hi 0 0 0
D.
0 0 0

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None.

8.

Which of the following are C preprocessors?

A.
#ifdef
B.
#define
C.
#endif
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

9.

What is the output of this C code?

    #include <stdio.h>

    int main()

    {

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

        void *p = &a[1];

        void *ptr = &a[2];

        int n = 1;

        n = ptr - p;

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

    }

 

A.
1
B.
4
C.
Compile time error
D.
Depends on the compiler

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

10.

Comment on the output of this C code?

    #include <stdio.h>

    int const print()

    {

        printf("pooripadhai.com");

        return 0;

    }

    void main()

    {

        print();

    }

 

A.
Error because function name cannot be preceded by const
B.
pooripadhai.com
C.
pooripadhai.com is printed infinite times
D.
Blank screen, no output
Submit your test now to view the Results and Statistics with answer explanation.