Horje
recursive function in c Code Example
recursive function in c
/*
Program: Factorial of a given number using recursive function.
Author: Codesansar
Date: Jan 22, 2018
*/
#include<stdio.h>
#include<conio.h>

int fact(int n); /* Function Definition */

void main()
{
 int num, res;
 clrscr();
 printf("Enter positive integer: ");
 scanf("%d",&num);
 res = fact(num); /* Normal Function Call */
 printf("%d! = %d" ,num ,res);
 getch();
}
int fact(int n) /* Function Definition */
{
 int f=1;
 if(n <= 0)
 {
  return(1);
 }
 else
 {
  f = n * fact(n-1); /* Recursive Function Call as fact() calls itself */
  return(f);
 }
}




C

Related
c challenge Code Example c challenge Code Example
how to make sure input is integer c Code Example how to make sure input is integer c Code Example
how to change file permissions in C language Code Example how to change file permissions in C language Code Example
online c compiler Code Example online c compiler Code Example
node.js Code Example node.js Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7