Q1. A function is AOnly a classBOnly a loopCOnly a variableDA block of code that performs a specific task Show answer Answer: D. A block of code that performs a specific task Report a mistake
Q2. The main advantage of using functions is AMaking program longerBIncreasing memory usage onlyCRemoving all errors automaticallyDCode reusability and modularity Show answer Answer: D. Code reusability and modularity Report a mistake
Q3. A function signature consists of AOnly return typeBOnly bodyCFunction name, return type and parameter listDOnly function name Show answer Answer: C. Function name, return type and parameter list Report a mistake
Q4. The return type void means AFunction returns integerBFunction returns nothingCFunction returns characterDFunction returns float Show answer Answer: B. Function returns nothing Report a mistake
Q5. Parameters listed in function definition are called AArguments onlyBGlobal variablesCActual parametersDFormal parameters Show answer Answer: D. Formal parameters Report a mistake
Q6. Values passed to a function when it is called are called AFormal parametersBLocal variables onlyCGlobal variablesDActual parameters / Arguments Show answer Answer: D. Actual parameters / Arguments Report a mistake
Q7. Local variables are accessible AOnly within the function in which they are declaredBOnly in header filesCEverywhere in the programDOnly in main() Show answer Answer: A. Only within the function in which they are declared Report a mistake
Q8. Global variables are accessible AOnly after main()BThroughout the programCOnly inside one functionDOnly in main() Show answer Answer: B. Throughout the program Report a mistake
Q9. An inline function is AAlways stored in memory separatelyBNever executedCOnly for classesDExpanded at the point of call (like macro) Show answer Answer: D. Expanded at the point of call (like macro) Report a mistake
Q10. Function overloading means AMultiple functions with same name but different parametersBOnly one function allowedCChanging return type onlyDMultiple functions with same name and same parameters Show answer Answer: A. Multiple functions with same name but different parameters Report a mistake
Q11. Default arguments in a function AAre compulsoryBCannot be usedCOnly work with void functionsDAllow calling function with fewer arguments Show answer Answer: D. Allow calling function with fewer arguments Report a mistake
Q12. The return statement is used to AStart a loopBReturn a value from a function and exit itCOnly print a valueDOnly declare a variable Show answer Answer: B. Return a value from a function and exit it Report a mistake
Q13. A function must be AOnly written in header filesBDeclared or defined before it is calledCAlways defined after main()DNever declared Show answer Answer: B. Declared or defined before it is called Report a mistake
Q14. Function prototype is also known as AFunction definitionBFunction declarationCFunction callDFunction body Show answer Answer: B. Function declaration Report a mistake
Q15. The body of a function is enclosed in ACurly braces { }BAngle brackets < >CSquare brackets [ ]DParentheses ( ) Show answer Answer: A. Curly braces { } Report a mistake
Q16. Which of the following is a valid function call? Asum{a, b};Bsum a, b;Csum[a, b];Dsum(a, b); Show answer Answer: D. sum(a, b); Report a mistake
Q17. A function can return ANo value everBUnlimited valuesCAt most one valueDMultiple values directly Show answer Answer: C. At most one value Report a mistake
Q18. To return multiple values from a function we can use AOnly return statement multiple timesBPointers, references or structuresCNot possibleDOnly void Show answer Answer: B. Pointers, references or structures Report a mistake
Q19. Call by value means ANo value is passedBOriginal value is always changedCA copy of the argument is passedDAddress of argument is passed Show answer Answer: C. A copy of the argument is passed Report a mistake
Q20. Call by reference means AAddress of the argument is passedBA copy is passedCOnly constants are passedDValue cannot be changed Show answer Answer: A. Address of the argument is passed Report a mistake
Q21. In call by value, changes made inside function ADo not affect the original variablesBAlways affect the original variablesCCause compile errorDAffect only global variables Show answer Answer: A. Do not affect the original variables Report a mistake
Q22. In call by reference, changes made inside function AAre ignoredBAffect the original variablesCAffect only local copiesDDo not affect original variables Show answer Answer: B. Affect the original variables Report a mistake
Q23. Recursive function is a function that ACalls itselfBHas no parametersCNever returnsDCalls another function only Show answer Answer: A. Calls itself Report a mistake
Q24. Every recursive function must have AA base case (terminating condition)BNo conditionCInfinite callsDOnly global variables Show answer Answer: A. A base case (terminating condition) Report a mistake
Q25. Example of recursive function is ACalculating factorialBOnly addition of two numbersCOnly printing HelloDOnly loops Show answer Answer: A. Calculating factorial Report a mistake
Q26. Library functions are AWritten by the user onlyBPre-defined functions available in header filesCOnly constructorsDOnly main() Show answer Answer: B. Pre-defined functions available in header files Report a mistake
Q27. User-defined functions are AOnly main()BOnly operatorsCAlready available in librariesDWritten by the programmer Show answer Answer: D. Written by the programmer Report a mistake
Q28. The function main() returns Aint (usually)Bvoid onlyCchar onlyDfloat only Show answer Answer: A. int (usually) Report a mistake
Q29. A function with no parameters is declared as Afunction_name();Breturn_type function_name;Cfunction_name;Dreturn_type function_name(); Show answer Answer: D. return_type function_name(); Report a mistake
Q30. Passing array to a function is actually ANot possibleBCall by value (entire array is copied)COnly by returnDCall by reference (base address is passed) Show answer Answer: D. Call by reference (base address is passed) Report a mistake
Q31. The scope of formal parameters is AEntire programBLimited to the function bodyCGlobalDLimited to main() only Show answer Answer: B. Limited to the function body Report a mistake
Q32. Function overloading is an example of ARun-time polymorphismBEncapsulationCCompile-time polymorphismDInheritance Show answer Answer: C. Compile-time polymorphism Report a mistake
Q33. Can we overload functions only by return type? ANoBOnly with voidCOnly with intDYes Show answer Answer: A. No Report a mistake
Q34. Default arguments must be AMiddle parameters onlyBNot allowedCTrailing (rightmost) parametersDLeading parameters only Show answer Answer: C. Trailing (rightmost) parameters Report a mistake
Q35. Once a default argument is used, remaining arguments ACause errorBCannot have default valuesCMust also have default valuesDAre optional always Show answer Answer: C. Must also have default values Report a mistake
Q36. An inline function should be AVery largeBRecursive onlyCSmall and simpleDOnly void Show answer Answer: C. Small and simple Report a mistake
Q37. Advantage of inline function is ALess memory alwaysBNo advantageCMore readable onlyDFaster execution (avoids function call overhead) Show answer Answer: D. Faster execution (avoids function call overhead) Report a mistake
Q38. Disadvantage of excessive inlining is ASpeed always decreasesBCode size may increaseCNo disadvantageDCode size decreases Show answer Answer: B. Code size may increase Report a mistake
Q39. A function that does not return any value and does not take parameters is declared as Aint function_name();Bvoid function_name();Cfunction_name(void); onlyDNone Show answer Answer: B. void function_name(); Report a mistake
Q40. The keyword used for call by reference is A& (ampersand)B* (asterisk)C->D:: Show answer Answer: A. & (ampersand) Report a mistake
Q41. Function declaration is also required when AFunction is defined before main()BOnly for library functionsCNever requiredDFunction is defined after main() Show answer Answer: D. Function is defined after main() Report a mistake
Q42. Nested function (function inside function) is AAllowed freelyBOnly for main()CCompulsoryDNot allowed in C++ (standard) Show answer Answer: D. Not allowed in C++ (standard) Report a mistake
Q43. The actual parameters and formal parameters ANoneBMust have same namesCCan have different namesDMust have same data types only Show answer Answer: C. Can have different names Report a mistake
Q44. Number of actual and formal parameters must ABe differentBAlways be zeroCMatch (except with default arguments)DNever match Show answer Answer: C. Match (except with default arguments) Report a mistake
Q45. A function can be called AAny number of timesBOnly from main()COnly onceDOnly from other functions Show answer Answer: A. Any number of times Report a mistake
Q46. Stack is used for AFunction calls and local variablesBOnly arraysCOnly classesDOnly global variables Show answer Answer: A. Function calls and local variables Report a mistake
Q47. Activation record / Stack frame stores AOnly codeBLocal variables, return address, parametersCOnly global dataDOnly objects Show answer Answer: B. Local variables, return address, parameters Report a mistake
Q48. When a function finishes execution, control returns to AOperating system onlyBThe beginning of main()CThe point from where it was calledDThe end of program Show answer Answer: C. The point from where it was called Report a mistake
Q49. Preprocessor directive for mathematical functions is A#include <vector>B#include <cmath>C#include <string>D#include <iostream> Show answer Answer: B. #include <cmath> Report a mistake
Q50. The overall benefit of functions is ARemoving need for variablesBBetter organization, reusability and readability of codeCMaking code longer and complexDEliminating all bugs automatically Show answer Answer: B. Better organization, reusability and readability of code Report a mistake