C Program Of Recursion

C Program Of Recursion

//Factorial of a no. using recursion

#include<stdio.h>

int Fact(int);     //function declaration

main()
{

   int a,y;
   printf("\n");    //newline

   printf("Enter value of a:");    //user give input
   scanf("%d",&a);

   printf("\n");


   y=Fact(a);    //function call

   printf("Factorial of a is :%d",y);
   printf("\n\n");

 }

int Fact(int a)

 {
  int z;
  if(a==0)
 {
  return 1;
 }
 z=a*Fact(a-1);
return z;

 
 }

Related Posts