Write C Program to find factorial of number using Recursion

 TASK-

Write C Program to find factorial of number using Recursion.

CODE:

#include<stdio.h>
int fact(int x);


int main(){
int x,f;

//Asking for number
printf("Enter the Number: ");
scanf("%d",&x);

f=fact(x); //Calling function

printf("\n\nThe Factorial of %d is %d",x,f);

getchar();
return 0;
}

 //Defining function 
int fact(int x)
{
if (x==0)
return 1;
else
return (x*fact(x-1));
}

Expected Output:






NEED WORK PRODUCE WORK

My name is Abdul Rehman I am from Pakistan. I am doing BS in Computer and information sciences. Currently, I am creating these blogs to help students of computer sciences all over the world..

1 Comments

  1. Really appreciate your work.It is really helpful, keep doing it bro.

    ReplyDelete
Post a Comment
Previous Post Next Post