Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 136 - 137 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 136

Describe in Detail Essay▾

  1. void main ()
  2. {
  3. int d =5;
  4. printf ( “%f” ,d);
  5. }
Edit

Explanation

  • In the program
Table Showing the Program
int d = 5;
  • Define the integer variable d = 5.
printf ( “% f” , d) ;
  • Here print the value of d but using the float
  • So compiler can՚t decide the output

Question 137

Describe in Detail Essay▾

What do you mean by inline function?

Edit

Explanation

  • Inline function is used with classes.
  • For inline function, the compiler places a copy of the code of that function at each call at compile time.
  • Function define in a class definition is an inline function definition, even without the use of the inline keyword.

Advantages of inline function:

  • Function call overhead doesn՚t occur.
  • Saves the overhead of pushing variables on the stack when function is called.
  • Saves overhead of a return from a function.
  • Useful for embedded system because inlined small functions produce lesser code than the function call preamble and return.

Disadvantages of inline function:

  • Too many inline functions result in large of the binary executable, because of code duplication.
  • Inline functions reduce instruction cache hit rate, thus reducing the speed of instruction fetch.
  • Increase compile time overhead since code any change in code inside the inline function means all the calling location will be recompiled.
  • It is not use many embedded system, because system code size is more important than speed.