Home » Blog » How will you print numbers from 1 to 100 without using loop?

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

We can use recursion for this purpose.

void printNos(unsigned int n) 
{ 
  if(n > 0) 
  { 
    printNos(n-1); 
    printf("%d ",  n); 
  }  
}

 

Leave a Reply

Your email address will not be published.