Javatpoint Logo
Javatpoint Logo

C Functions Test 4


16) What is the output of below program?

  1. Print 1
  2. Print 10
  3. Print 20
  4. Compile error

The correct option is (d).

Explanation:

There is an error in the line 16 i.ea>=45 ? return(*y): return(*z); we are not allowed to use return keyword in the ternary operator

Therefore compile error occur in the output of a program

17) What is the output of below program?

  1. Hi
  2. Hello Hi
  3. No output
  4. Infinite loop

The correct option is (a).

Explanation:

Step 1: int j; The variable j is declared as an integer type.

Step 2: int function(); This statement tells the compiler that the function does not accept any argument and it returns an integer value.

Step 3: while(j) The value of j is not initialized so the while condition is failed. Therefore it does not execute the while block.

Step 4: printf("Hi\n"); This statement prints "Hi".

Therefore the output of the program is "Hi".

18) The C library function rewind() is used for re-position the file pointer at the beginning of the file.

  1. True
  2. False

The correct option is (a).

Explanation:

In C, rewind function reposition the file position at the beginning of the file of given stream.

The syntax of using function rewind() is:

void rewind(FILE *stream)

This function also erases the error and end-of-file indicators for stream.

19) Which header file is used for supporting the functions- malloc() and calloc().

  1. stdio.h
  2. math.h
  3. stdlib.h
  4. memory.h

The correct option is (c).

Explanation:

void *calloc(size_h nitems, size_h size): Function calloc() requires the double argument.

void *malloc(size_h size) : Function malloc() requires the single argument.

For supporting the function- malloc() and calloc() stdlib.h header file is required.

20) A function can execute faster than a macro.

  1. True
  2. False

The correct option is (b).

Explanation:

Macro can be executed faster with no overhead of context switch because the code of macro gets expanded at the line of call.

Therefore, the above statement is false.





Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA