Skills101
← All practice quizzes

Quiz: C Functions and Recursion

5 questionsNo time limitPass: 60%+10 XP on first pass

Write and call functions, declare prototypes, understand call by value with a picture, recursion with a base case, and the storage classes auto, static, extern and register.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    #include <stdio.h>
    void change(int x) { x = 100; }
    int main(void) {
        int a = 1;
        change(a);
        printf("%d", a);
        return 0;
    }
    
  2. Question 2

    What does this print?

    #include <stdio.h>
    int f(int n) {
        if (n == 0) return 0;
        return n + f(n - 1);
    }
    int main(void) {
        printf("%d", f(5));
        return 0;
    }
    
  3. Question 3

    What does this print?

    #include <stdio.h>
    int next(void) {
        static int n = 10;
        return n++;
    }
    int main(void) {
        next(); next();
        printf("%d", next());
        return 0;
    }
    
  4. Question 4

    What is the default initial value of a static local int?

  5. Question 5

    What happens if a recursive function has no base case?