Alright, I am back and I have a new program that I have been working on all day. It's funny because I'm sure most of you guys could do this in 1 minute. But as I said before I am 49 years old and do not use computers, just trying to help my son while he is hospitalized.
I need to know once again, is this a correct use of recursion?? Or, is this even recursion at all?? I sure hope that it is, because I would like to go to sleep. Please let me know, and thanks in advance!
#include <iostream>
using namespace std;
void print(const char *s, int val)
{
while (--val >= 0)
printf("%s",s);
}
void printSpace(const char *t, int space)
{
while (--space >= 0)
printf(" %",t);
}
void recursiveFunction(int val, int space)
{
if (val<=3){
printSpace(" ",--space);
print("* ",val);
cout <<endl;
recursiveFunction(val + 1,space);
printSpace(" ",space);
print("* ",val);
cout <<endl;
}
else{
print("* ",val);
cout <<endl;
}
}
int main()
{
recursiveFunction(1,4);
return 0;
}