You write this code into any c compiler and get factorial of given number by run this code.
C Program Code
//factorial of a number
#include "stdio.h"
#include "conio.h"
void main()
{
int fact=1,n;
clrscr();
printf("enter any number");
scanf("%d",&n);
while(n>0)
{
fact=fact*n;
n--;
}
printf("\n factorial of given number= %d",fact);
getch();
}
Input/Output
enter any number 4
factorial of given number= 24
Factorial of 4 = 4*3*2*1 =24
Wednesday, November 10, 2010
Popular Posts
- Generate Prime Number Series in Java Programming
- Java Function Code to create Reverse Linked List of Singly Linked List (In memory pointer changes)
- C Program to Print Patterns of Numbers
- Exception Handling Program in Java - How to Handle Exception in Java
- Reverse a Number in PL/SQL Programming
- C Program For Pascal's Triangle - Pattern Pascal's Triangle in C Programming
- Factorial Program in Java Using Class
- Exception Handling Program in PL/SQL Oracle
- Difference Between White Box And Black Box Framework
- Java File Handling Program - How to Handle File in Java
2 comments:
this program will not work i don't know why...
but its only work up to number 6 then its start giving garbage value after that.
bcoz the datatype is int, u should giv it as long int....
Post a Comment
Dont SPAM