Ask Question
9 June, 14:36

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

+4
Answers (1)
  1. 9 June, 16:16
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers