✏️ Explanatory Question

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

👁 1,206 Views
📘 Detailed Answer
💡

Answer with Explanation

//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);
  } 
}