NextIndexPrevious

Programs in C language

2. Program to find the factorial of given number.
#include<stdio.h>
#include<conio.h>

void main()
{
    int n, p=1;
    clrscr();
    printf("Enter a number:");
    scanf("%d",&n);
    
    while(n>0)
    {
    	p = p * n;
        n--;
     }
     
     printf("Factorial of given number : %d",p);
     getch();
}
Input :

6
Output :

720



Father of C Language
Dennis Ritchie

Dennis Ritchie

Born: September 9, 1941, Bronxville
Died: October 9, 2011, Murray Hill