Skip to content

Commit

Permalink
Merge pull request #540 from Rimjhim28/patch_1
Browse files Browse the repository at this point in the history
Print 1 to N using indirect recursion using Java
  • Loading branch information
ambujraj authored Oct 7, 2018
2 parents c5c8943 + c0134d9 commit 2da29de
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions print1toN/using_indirect_recursion.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

// C program to print from 1 to N using
// indirect recursion/
#include<stdio.h>

// We can avoid use of these using references
#define N 20;
int n = 1;

// Prints n, increments n and calls fun1()
void fun1()
{
if (n <= N)
{
printf("%d", n);
n++;
fun2();
}
else
return;
}

// Prints n, increments n and calls fun2()
void fun2()
{
if (n <= N)
{
printf("%d", n);
n++;
fun1();
}
else
return;
}

// Driver Program
int main(void)
{
fun1();
return 0;
}

0 comments on commit 2da29de

Please sign in to comment.