The thing that I've noticed is that the actual task was
to decrement counter if it's greater than 1. So I would
like to know if I could go about it without a recursive function,
like this code example below:
//without recursive function
#include <iostream>
using namespace std;
Recursion can be seen as a LOOP of function calls. It's sometimes advisable to use recursion above a loop, because of complexity. In your case, a simple for loop will do the trick:
void myFunction(int counter)
{
if(counter == 1) return; // If the input is 1, end the function
else // In all other cases:
{
cout <<counter<<endl; // Show the input
cout << --counter; // Show the input-1
return; // End the function
}
}