Class 7 Exam  >  Class 7 Questions  >  In which of the following cases inline functi... Start Learning for Free
In which of the following cases inline functions may not word?
i) If the function has static variables.
ii) If the function has global and register variables.
iii) If the function contains loops
iv) If the function is recursive
  • a)
    i, iv
  • b)
    iii, iv
  • c)
    ii, iii, iv
  • d)
    i, iii, iv
Correct answer is option 'D'. Can you explain this answer?
Most Upvoted Answer
In which of the following cases inline functions may not word?i) If th...
Explanation:

Inline functions are a way to improve the performance of a program by reducing the function call overhead. They are typically used for small, frequently used functions. However, there are certain cases where inline functions may not work properly.

i) If the function has static variables:
- Static variables are initialized only once and retain their values between function calls.
- If an inline function contains static variables, each time the function is called, the static variables will be initialized again, which can lead to unexpected behavior.
- Therefore, inline functions may not work correctly when they have static variables.

ii) If the function has global and register variables:
- Global variables are accessible throughout the program, and register variables are stored in CPU registers for faster access.
- If an inline function uses global or register variables, it may not work properly because these variables have a wider scope than the function itself.
- Inlining the function may cause conflicts with other parts of the program that also use the same global or register variables.

iii) If the function contains loops:
- Inline functions are expanded at the call site, which means the function code is inserted directly into the calling code.
- If the inline function contains loops, the loop code will be replicated at each call site, which can lead to code bloat and decreased performance.
- Therefore, inline functions may not be suitable for functions that contain loops.

iv) If the function is recursive:
- Recursive functions are functions that call themselves.
- Inline functions cannot be recursive because inlining would lead to an infinite loop where the function keeps calling itself repeatedly.
- Therefore, inline functions may not work for recursive functions.

Conclusion:
- Based on the above explanations, inline functions may not work properly in cases where the function has static variables, global and register variables, loops, or is recursive.
- Hence, the correct answer is option 'D' - i, iii, iv.
Free Test
Community Answer
In which of the following cases inline functions may not word?i) If th...
A function is not inline if it has static variables, loops or the function is having any recursive calls.
Attention Class 7 Students!
To make sure you are not studying endlessly, EduRev has designed Class 7 study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Class 7.
Explore Courses for Class 7 exam

Top Courses for Class 7

In which of the following cases inline functions may not word?i) If the function has static variables.ii) If the function has global and register variables.iii) If the function contains loopsiv) If the function is recursivea)i, ivb)iii, ivc)ii, iii, ivd)i, iii, ivCorrect answer is option 'D'. Can you explain this answer?
Question Description
In which of the following cases inline functions may not word?i) If the function has static variables.ii) If the function has global and register variables.iii) If the function contains loopsiv) If the function is recursivea)i, ivb)iii, ivc)ii, iii, ivd)i, iii, ivCorrect answer is option 'D'. Can you explain this answer? for Class 7 2024 is part of Class 7 preparation. The Question and answers have been prepared according to the Class 7 exam syllabus. Information about In which of the following cases inline functions may not word?i) If the function has static variables.ii) If the function has global and register variables.iii) If the function contains loopsiv) If the function is recursivea)i, ivb)iii, ivc)ii, iii, ivd)i, iii, ivCorrect answer is option 'D'. Can you explain this answer? covers all topics & solutions for Class 7 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for In which of the following cases inline functions may not word?i) If the function has static variables.ii) If the function has global and register variables.iii) If the function contains loopsiv) If the function is recursivea)i, ivb)iii, ivc)ii, iii, ivd)i, iii, ivCorrect answer is option 'D'. Can you explain this answer?.
Solutions for In which of the following cases inline functions may not word?i) If the function has static variables.ii) If the function has global and register variables.iii) If the function contains loopsiv) If the function is recursivea)i, ivb)iii, ivc)ii, iii, ivd)i, iii, ivCorrect answer is option 'D'. Can you explain this answer? in English & in Hindi are available as part of our courses for Class 7. Download more important topics, notes, lectures and mock test series for Class 7 Exam by signing up for free.
Here you can find the meaning of In which of the following cases inline functions may not word?i) If the function has static variables.ii) If the function has global and register variables.iii) If the function contains loopsiv) If the function is recursivea)i, ivb)iii, ivc)ii, iii, ivd)i, iii, ivCorrect answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of In which of the following cases inline functions may not word?i) If the function has static variables.ii) If the function has global and register variables.iii) If the function contains loopsiv) If the function is recursivea)i, ivb)iii, ivc)ii, iii, ivd)i, iii, ivCorrect answer is option 'D'. Can you explain this answer?, a detailed solution for In which of the following cases inline functions may not word?i) If the function has static variables.ii) If the function has global and register variables.iii) If the function contains loopsiv) If the function is recursivea)i, ivb)iii, ivc)ii, iii, ivd)i, iii, ivCorrect answer is option 'D'. Can you explain this answer? has been provided alongside types of In which of the following cases inline functions may not word?i) If the function has static variables.ii) If the function has global and register variables.iii) If the function contains loopsiv) If the function is recursivea)i, ivb)iii, ivc)ii, iii, ivd)i, iii, ivCorrect answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice In which of the following cases inline functions may not word?i) If the function has static variables.ii) If the function has global and register variables.iii) If the function contains loopsiv) If the function is recursivea)i, ivb)iii, ivc)ii, iii, ivd)i, iii, ivCorrect answer is option 'D'. Can you explain this answer? tests, examples and also practice Class 7 tests.
Explore Courses for Class 7 exam

Top Courses for Class 7

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev