Ask Question
5 March, 04:31

Modify the countUp () you wrote in the previous question to countUp (num), where num is a parameter. The function displays from 1 to num.

+2
Answers (1)
  1. 5 March, 05:24
    0
    void countUp (int num)

    {

    if (num==0) / /base case.

    return;

    countUp (num-1); //Recursive call.

    cout<
    }

    for input num=25

    Output:-1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

    Explanation:

    I have used recursion to print the numbers the function is in c+ + language. In every recursive call we are decreasing num by 1. As the base case is reached. Then it will backtrack from 1 to num and then we are printing while backtracking.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Modify the countUp () you wrote in the previous question to countUp (num), where num is a parameter. The function displays from 1 to num. ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers