← Back to Question List
C++ Code Walkthrough #48
Recursion with a Step of Two
📄 Code
Read carefully — what does this print?1#include <iostream>2using namespace std;34int f(int n) {5 if (n <= 0) return 0;6 return n + f(n - 2);7}89int main() {10 cout << f(7) << endl;11 return 0;12}