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

Subject Programming Language

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>

int main(){

  int i,f=1,num;

 

  printf("Enter a number: ");

  scanf("%d",&num);

 

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

      f=f*i;

 

  printf("Factorial of %d is: %d",num,f);

  return 0;

}

 

Login to post your comment.