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
Explanation
- In the program
int d = 5; |
|
printf ( “% f” , d) ; |
|
Question 137
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.