Skip to content

Instantly share code, notes, and snippets.

@msuryaprakash
Last active December 7, 2015 11:09
Show Gist options
  • Save msuryaprakash/9ffa300926ce018050cc to your computer and use it in GitHub Desktop.
Save msuryaprakash/9ffa300926ce018050cc to your computer and use it in GitHub Desktop.
/* PROGRAM TO PRINT NUMBERS OF 1 TO N WITHOUT USING ANY LOOPS */
#include<stdio.h>
void Print_Numbers(int,int); //Declaring the Function Definition
main()
{
int NUM;
printf("\n *** Prime Numbers Program in C With Out Using any loops ***");
printf("\n Enter Number of Primes Numbers Required: ");
scanf("%d",&NUM); //the value is given by the user
Print_Numbers(1,NUM); //calling the function
}
void Print_Numbers(int i,int max)
{
printf("%d\n",i);
if(i<max)
{
//Calling the Function Recursively
Print_Numbers(++i,max);
}
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment