Javatpoint Logo
Javatpoint Logo

C Functions Test 3

11) If the integer data type (int) is 2 bytes wide, what is the output of below program?

  1. gh
  2. ab
  3. ef
  4. cd

The correct option is (c).


The output of the above program will be ef in Windows (Turbo C) and ab in Linux (GCC).

Since C is a machine dependent language therefore sizeof(int) may return different values in different operating system.

In Windows operating system sizeof(int)=2 bytes.

In Linux operating system sizeof(int)=4 bytes.

The given size of int is 2 bytes therefore program output is based on the Windows (Turbo C) compiler. Therefore the output of program is ef.

12) Find out the error in the below program?

  1. Error: Doesn't print anything
  2. Error: Not allowed assignment
  3. No error
  4. None of the above

The correct option is (b).


The void f() function is not visible to the compiler while going through main() function.

Hence we need to declare this prototype void f(); before the main() function. This kind of error is not occurring in modern compiler.

Therefore on compiling the above program it give Error: Not allowed assignment.

13) Which statement is correct about the below program?

  1. Error: main() cannot be called inside printf()
  2. It prints the garbage values infinitely
  3. Runs infinitely without printing anything
  4. No Error and print nothing

The correct option is (c).


In printf statement i.e. printf("%p\n", main()); This statement calls the main() function and then it repeats infinitely, until the stack is overflow.

Therefore program runs infinitely without printing anything.

14) Functions can only be called either by value or reference.

  1. True
  2. False

The correct option is (a).


A function can be called either using call by reference or call by value. Therefore the above statement is true.

For Example:

Call by reference meansc=sub(&x, &y); here the address of x and y are passed.

Call by value means c= sub(x, y); here the value of x and y are passed.

15) If two "return" statements are used in a function successively, the compiler will generate warnings.

  1. True
  2. False

The correct option is (a).


Yes, if a function contains two return statements successively then the compiler will generate "Unreachable code" warning in second return statement.

For Example:

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA