__Description:__
Factorial of a number is nothing
but the multiplication of numbers from a given number to 1

**main program**

__Algorithm:__
Step 1: start

Step 2: read n

Step 3: call sub program as
f=fact(n)

Step 4: print f value

Step 5: stop

__Sub program:__
Step 1: initialize the f

Step 2: if n= = 0 or n == 1 return
1 to main program if not goto step 3

Step 3: return n*fact(n-1) to main
program

__Program:__
#include<stdio.h>

#include<conio.h>

int fact(int n)

{

int f;

if((n==0)||(n==1)) // check the condition for the n value

return(n);

else

f=n*fact(n-1); //calculate the factorial of n

return(f);

}

void main()

{

int n;

clrscr();

printf("enter the number :");

scanf("%d",&n);

printf("factoria of
number%d",fact(n));

getch();

}

__Output:__
1. Enter the number : 5

Factorial of
number: 120

2. Enter the number : 3

Factorial of
number: 6

3. Enter the number : 9

Factorial of
number: -30336

**the program is error free**

__Conclusion:__

__VIVA QUESATIONS:__
1) What
is the meaning of factorial number?

**Ans :**Factorial of a number is nothing but the multiplication of numbers from a given

number to 1

2) What
is the meaning of recusive function ?

Ans: A function call
it self is called recursive function

3) define
library functions ?

Ans: The functions have already been written, compiled and
placed in libraries and are

called
library functions.

4) Define
formal parameters ?

Ans: Formal
parameters are the parameters given in
the function declaration ans

function definition.

## No comments:

## Post a Comment