My professor asked me to do this:
Input Number: 5
+++++
+++++
+++++
+++++
+++++
I've been trying so hard to get thi; I kept on ending up with a " + " with a huge blank and " + ".
Can you please help me fix this code in C?
#include <stdio.h>
#include <conio.h>
int space(int space1)
{
if(space1 == 0)
{
return 1;
}
else
{
return printf("\n") && space(space1 - 1);
}
}
int visual(int plus)
{
if (plus == 0)
{
return 1;
}
else
{
return printf("+") && visual (plus - 1) && space(plus - 1);
}
}
int main()
{
int number;
printf("Please give the number\n");
scanf("%d",&number);
visual(number);
getch();
}
A new edit; frustrating for me. It gives me 5 rows of + and a big space.
&&is doing, and what the return value of printf is..do you really need it? IMO it just complicates everything..