Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print 1 to N using indirect recursion using Java #540

Merged
merged 1 commit into from
Oct 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}