Home / Questions / How will you print numbers from 1 to 100 without using a loop?
Explanatory Question

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

👁 1,206 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

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