This version1 of the code is a recursive function to print n to 0 values, but there is no return statement, is it using the return value of printf
The version 2 of the code prints from 0 to n,and it worked even if we remove the return keyword as shown in version 3
help me understand the hidden things in the version1 and version3
Version 1
void print(int pme)
{
if(pme >= 0)
{
printf("%d",pme);
print(pme -1);
}
}
version 2
int print(int pme)
{
if(pme == 0)
return printf("%d,",pme);
else
{
print(pme-1);
return printf("%d,",pme);
}
}
version 3
int print(int pme)
{
if(pme == 0)
printf("%d,",pme);
else
{
print(pme-1);
printf("%d,",pme);
}
}