Question

Differentiate between Recursion and Iteration. Give suitable code to find factorial of a number entered by user in C for each.

27 Apr 2023
Answer :
Word Count : 642
Recursion Iteration
Recursion is a programming technique where a function calls itself to solve a problem. Iteration is a programming technique where a set of instructions are repeated in a loop until a certain condition is met.
Recursion involves breaking down a complex problem into smaller subproblems and solving them in a recursive manner. Iteration involves executing a set of instructions repeatedly until a specific condition becomes false.
In recursive functions, the base case(s) determine when the function stops calling itself and returns a result. In iterative loops, the termination condition decides when the loop stops executing and moves to the next statement outside the loop.
Recursion typically uses more memory as each recursive call creates a new instance of the function on the call stack. Iteration generally uses less memory as it uses a fixed number of variables to control the loop execution.
Recursive functions are generally shorter and more concise, as they rely on the base case(s) and recursive calls to solve the problem. Iterative loops often require more code to initialize variables, update them, and check the termination condition.
Recursive functions can be more intuitive for solving problems that can be naturally broken down into subproblems. Iteration is often favored for repetitive tasks and situations where the problem doesn't naturally lend itself to recursion.
Recursive algorithms can sometimes be slower compared to iterative algorithms due to the overhead ___ _______ ___ _____ ________ _____ _____ _____ _________.
_____ ________ _____ _________ _____ _____ __________ _________ ___.
___ _____ _________ ___ ________ ______.
_____ _____ _________ ________ ___ __________.
___ __________ ________ ________ _______ _____ _____ ______ _________ ___.
_______ ______ ______ ________ _________.
__________ __________ ___ ___ ___ ______ _________.
____ ________ _____ ______ ___ ____.
_________ _________ ___ ___ _______ ___.
________ _________ _______ _____ _______ _______ _________ ______.
_________ ____ _____ _________ _________ __________ _______ _______ ____.
_______ ___ __________ ________ ___ ______ ______ ___ ____ __________ _____.
____ _______ __________ __________ _________ ____ _______ ____.
___ ___ ________ ________ _________ ____ ______ _______.
__________ ____ ______ ____ _______.
_______ __________ _____ __________ _________ ________.
_________ ________ ______ ______ ___.
________ ________ ___ _____ _________ __________ _______ ______ _____ __________ _________ ________.
__________ ______ ______ ___ __________ ____ _________ ________ ________.
_________ ________ _____ ______ _________ __________ _____ __________ _______ _________.
______ ______ _____ _______ _________ __________ __________ ___ _______.
________ ____ ________ ____ __________ __________ _____ _______ _________ __________ ___ _________.
______ _____ _________ ______ _________ ____.
__________ ________ _________ ________ __________ ______ _______ ___ ______ _____ _______.
___ ____ ________ _________ ________ ________ ________ __________ _______ ____ ______ ________.
___ ____ ____ ______ _________ ___ _________ ________ ________ ______.
_____ ___ _________ _________ _______ _________.
__________ _______ _______ _____ ____ ___ ______ _____ ___ ________.
_______ ____ ____ ___ ____ _____ ________ __________ ________.
_________ _______ ______ ______ _____ ______ ________ _______ ________.
__________ _______ __________ _______ _______ ______ ___ ________ _____ _______ ____ _______.
____ __________ ____ _________ ________ ____ _____ _________ __________.
__________ ____ __________ _______ _____ ___ __________ ___ ___.
___ ___ _________ _______ ____ _________ _________ __________ __________.
______ _____ ______ _______ _________ __________ ________ ____ __________ __________ ____ _________.
________ ______ ___ _____ _______ __________ _____ _________.
________ ________ _________ ________ _______ _____ ______ _____ __________ _______.
__________ _______ ________ ___ ______ _______ _________ ____ _______ ________ _______.
__________ ____ ________ _______ _______.
______ ____ _________ _______ ____ ______ _______.
_____ ____ _____ ______ _____ ___ _________ _______ ____ ___ _______ _____.
__________ _____ ____ ____ __________ ___ _________ __________.
____ _______ _______ _________ _______ ____ ___ _____ ________.
________ _________ ____ ___ _______.
______ ______ ____ _________ ________ ______ ________ ________ ________ _________.
__________ ________ ______ __________ _______.
______ ________.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top