find the factorial of a given number using c programming

To find the factorial of number, multiply continuously from 1 to that number.

for eg:- Factorial of 3 (ie. 3!) = 1 * 2 * 3 = 6

Factoria of 5 (ie. 5!) = 1 * 2 * 3* 4* 5 = 120

and so on.




void main()


int f=1,i,n;


printf("Enter a number\n");




f=f * i;



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




NB: stdio.h -------------> header file

conio.h ----------> heade file

int f=1 ----------> variable declaration & assigning values

scanf ---------------> getting value to the variable n from keyboard

f=f*i ----------------> value of f is multiplied by the value of i and save the result in to f.


More by this Author

Comments 20 comments

thajuudin 5 years ago

out put is 1 for every number witgh dz program

Tamanna Jain 3 years ago

Incorrect program

agarwal 3 years ago

Incorrect coding

k.d.shukla 2 years ago

it does not work for long integers

Somnath Karmakar 2 years ago

This is a bad programme ever ... so this is wrong please don't copy this anywhere;;;;;;;;; bogaaaaaaaaaassssssss

Johna86 2 years ago

Really informative article post.Thanks Again. Awesome. dfedcdadbbee

Pharmd588 2 years ago

Very nice site! cheap goods

blaze 2 years ago

abe kabhi jindhgi mai program banaye tha kya

Mantu 2 years ago

Your program is wrong. intialize i=1 above while loop. Then the program will execute correctly.

See this :

baba 2 years ago

sahi hai bhai bawkoof bnana raha hai

u.h shukla 2 years ago

Best programs

ashish 2 years ago

wrong program

ABC 2 years ago


A.b 2 years ago

ok ,this is correct;

ashok rana 2 years ago

Nice program

raj 2 years ago

Isko program banane nahi aate ...

Aajaate hai program likhne...

Guru 2 years ago

Superb program

indumathy 2 years ago

very usefull for me

abi 23 months ago


deepak 23 months ago

Not bad

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.

    Click to Rate This Article