How will you print numbers from 1 to 100 without using a loop?

C Programming Language >   Loop control in C Language >   Loop Introduction in C  

Long Question

1281


Answer:

 
//We can use recursion for this purpose.

/* Prints numbers from 1 to n */
void printNos(unsigned int n)
{
  if(n > 0)
  {
    printNos(n-1);
    printf("%d ",  n);
  } 
}


This Particular section is dedicated to Question & Answer only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.




Join Our telegram group to ask Questions

Click below button to join our groups.