-->

Facebook

Jasper Roberts - Blog

Tuesday, April 28, 2015

Write a program to find factorial of a number using recursion.

#include<stdio.h>
#include<conio.h>
int fac(int n);

void main()
 {
  int x;
  long int a;
  clrscr();
  printf("enter the no:");
  scanf("%d",&x);
  a=fact(x);
  printf("factorial=%d",a);
  getch();
 }
 int fact(int n)
 {
 if(n==1)
  return 1;
 else
  return n*fact(n-1);
 }

No comments:

Post a Comment