Interactive Quiz for Chapter 17

Question
Your Answer Result/Explanation
18.1
What is the output of the following code?
    #include  
    using namespace std;

    int m(int r) 
    {
      return r > 2 ? r * m(r - 1) : r;
    }

    int main()
    {
      cout << m(4);
      return 0;
    }
                  
18.2
What is the output of the following code?
    #include  
    using namespace std;

    void m(int r) 
    {
      if (r > 2) {
        cout << r << " ";
        m(r - 1);
      }
    }

    int main()
    {
      m(4);
      return 0;
    }
                  
18.3
What is the output of the following code?
    #include  
    using namespace std;

    void m(int r) 
    {
      if (r >= 2) {
        cout << r << " ";
        m(r - 1);
      }
    }

    int main()
    {
      m(4);
      return 0;
    }