Method1 (Using recursion)
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;
}
Saturday, December 5, 2009
A program to print numbers from 1 to 100 without using loops
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment