find the factorial of a given number using c programming

Updated on March 24, 2010

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.

-------------------------------------------------------

#include<stdio.h>

#include<conio.h>

void main()

{

int f=1,i,n;

clrscr();

printf("Enter a number\n");

scanf("%d",&n)

while(i<=n)

{

f=f * i;

i=i+1;

}

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

getch();

}

---------------------------------------------------------------------

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.

----------------------------------------------------------------------

Popular

10

22

• Data Types in C Programming Language

269

0 of 8192 characters used

• deepak

3 years ago

• abi

3 years ago

nice

• indumathy

3 years ago

very usefull for me

• Guru

3 years ago

Superb program

• raj

4 years ago

Isko program banane nahi aate ...

Aajaate hai program likhne...

• ashok rana

4 years ago

Nice program

• A.b

4 years ago

ok ,this is correct;

• ABC

4 years ago

JHATU PROGRAM

• ashish

4 years ago

wrong program

• u.h shukla

4 years ago

Best programs

• baba

4 years ago

sahi hai bhai bawkoof bnana raha hai

• Mantu

4 years ago

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

http://www.java-programming-tutorial.com/2014/07/j...

• blaze

4 years ago

abe kabhi jindhgi mai program banaye tha kya

• Pharmd588

4 years ago

Very nice site! cheap goods http://yieopxa2.com/yxyaovx/4.html

• Johna86

4 years ago

Really informative article post.Thanks Again. Awesome. dfedcdadbbee

• Somnath Karmakar

4 years ago

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

• k.d.shukla

4 years ago

it does not work for long integers

• agarwal

4 years ago

Incorrect coding

• Tamanna Jain

5 years ago

Incorrect program

• thajuudin

7 years ago

out put is 1 for every number witgh dz program

working