C Quiz: Recursion

This C quiz tests recursion, functions that call themselves. You will trace calls step by step, see how printing before or after the recursive call changes the output, and pick correct base cases.

मीडियम 10 सवाल ~6 मिनट पास होने के लिए 80% C17

मोड चुनें

आप गेस्ट के तौर पर खेल रहे हैं: XP और streak सेव रखने के लिए साइन इन करें।

सैंपल सवाल

सवाल 1 / 10

What does this print?

#include <stdio.h>

int fact(int n) {
    if (n <= 1) return 1;
    return n * fact(n - 1);
}

int main(void) {
    printf("%d\n", fact(5));
    return 0;
}
जवाब दिखाएं

D. 120 fact(5) is 5 * 4 * 3 * 2 * 1 = 120; the recursion stops at the base case n <= 1. 24 is fact(4) and 15 is 5 + 4 + 3 + 2 + 1.

इस क्विज़ में क्या है

  • Base case and recursive case
  • Tracing factorial, Fibonacci and digit sums
  • Work done before vs after the recursive call
  • Counting calls in naive Fibonacci
  • Stack frames and mutual recursion

अक्सर पूछे जाने वाले सवाल

क्या अकाउंट ज़रूरी है?

नहीं। कोई भी खेल सकता है। XP, streak, badge और हिस्ट्री सेव रखने के लिए साइन इन करें।

क्या मैं इसे दोबारा दे सकता हूं?

हां। आपका बेस्ट स्कोर सेव रहता है, और हर बार सवाल और जवाब शफ़ल होते हैं।