Order PDF of any content from our website with a little minor Fee to donate for hard work. Online MCQs are fully free but PDF books are paid. For details: contact whatsapp +923028700085 Important notes based PDF Books are available in very little price, starting from 500/-PKR; Order Now: contact whatsapp +923028700085

Past Papers CS201- Midterm Solved Questions on Recursion and Arrays in C Programming

Q#1: What is the recursive definition of calculating x to the power of n (xⁿ)?
Answer: The recursive definition is xⁿ = x * xⁿ⁻¹. The recursion stops when the base case is reached, i.e., when n is 1 or 0.


Q#2: How does the recursive function for computing factorials work, and when does it terminate?
Answer: The recursive factorial function multiplies the current n with fact(n-1). The recursion terminates when the base case (n <= 1) is reached.


Q#3: Why might using recursive functions come with a trade-off?
Answer: Recursion adds elegance to code but can cause memory and stack overhead due to multiple function calls. For efficiency, iterative (non-recursive) solutions may be preferred in some cases.


Q#4: In the context of arrays, what is the purpose of the for loop mentioned for calculating the average age?
Answer: The for loop is used to input the ages of 10 students into the age array, using the loop variable i as the index to store each age in the corresponding element.

Contents Copyrights Reserved By T4Tutorials