What is recursion? Write a "C" program that will calculate the factorial of given integer.

Subject Programming Language
NU Year Set: 2.(d) Marks: 6 Year: 2013

Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function.


#include <stdio.h>

void main()


    int i, fact = 1, num;


    printf("Enter the number \n");

    scanf("%d", &num);

    if (num <= 0)

        fact = 1;



        for (i = 1; i <= num; i++)


            fact = fact * i;



    printf("Factorial of %d = %5d\n", num, fact);



Login to post your comment.