Thursday, November 1, 2012

A simple program to understand recursion

#include <stdio.h>
#include <conio.h>

void recTest(int i)
{
    if(i > 0)
    {
        recTest(i - 1);          //understand this crazy little insane item
        printf("%i\n", i);
    }
}

int main()
{
    recTest(5);
}


OUTPUT:
1
2
3
4
5

No comments:

Post a Comment