C Language | 10 Minute‐Test 9


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?
(7 and 8 are entered)

#include <stdio.h>

   void main()

   {

       float x;

       int y;

       printf("enter two numbers \n", x);

       scanf("%f %f", &x, &y);

       printf("%f, %d", x, y);

   }

 

A.
7.000000, 7
B.
Run time error
C.
7.000000, junk
D.
Varies

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None.

2.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         for (; ; ;)
  6.             printf("In for loop\n");
  7.             printf("After loop\n");
  8.     }

A.
Compile time error
B.
Infinite loop
C.
After loop
D.
Undefined behaviour

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None

3.

What is the scope of an external variable?

A.
Whole source file in which it is defined
B.
From the point of declaration to the end of the file in which it is defined
C.
Any source file in a program
D.
From the point of declaration to the end of the file being compiled

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

None.

4.

C99 standard guarantees uniqueness of ____ characters for internal names.

A.
31
B.
63
C.
12
D.
14

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

5.

Which of the following is true for variable names in C?

A.
They can contain alphanumeric characters as well as special characters
B.
It is not an error to declare a variable to be one of the keywords(like goto, static)
C.
Variable names cannot start with a digit
D.
Variable can be of any length

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

According to the syntax for C variable name, it cannot start with a digit.

6.

What is the output of this C code?

#include <stdio.h>

   int main()

   {

       int x = 0, y = 2;

       int z = ~x & y;

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

   }

 

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

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Size of any type of pointer is 4 on a 32-bit machine.

7.

The output of the code below is

#include <stdio.h>

   void main()

   {

       int i = 0, k;

       label: printf("%d", i);

       if (i == 0)

           goto label;

   }

 

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

8.

Comment on the output of this C code?

A.
void
B.
int
C.
short int
D.
double

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None.

9.

#include statement must be written

A.
Before main()
B.
After main()
C.
Before any scanf/printf
D.
It can be written anywhere

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Using these directives before main() improves readability.

10.

The preprocessor provides the ability for _______________.

A.
The inclusion of header files
B.
The inclusion of macro expansions
C.
Conditional compilation and line control.
D.
All of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The preprocessor provides the ability for the inclusion of header files, macro expansions, conditional compilation, and line control.


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