void printUp(int startNumber, int endNumber)
{
if (startNumber > endNumber)
return;
printf("[%d]\n", startNumber++);
printUp(startNumber, endNumber);
}
Method2 (Using goto)
void printUp(int startNumber, int endNumber)
{
start:
if (startNumber > endNumber)
{
goto end;
}
else
{
printf("[%d]\n", startNumber++);
goto start;
}
end:
return;
}
No comments:
Post a Comment