Tuesday, 1 January 2019

Filled Under:

Factorial of a number[c programming examples with output]

C programming examples with output

Factorial of a number

Program
#include<stdio.h>
#include<conio.h>
main()
{
       int a,b,c;
       clrscr();
       printf("Enter any number: ");
       scanf("%d",&a);
       c=a;
       b=1;
       while(c>0)
       {
       b=b*c;
       c-;
       }
       printf("Factorial of %d is:  %d",a,b);
       getch();
}

Output

Enter any number:6
Factorial of 6 is:720


0 komentar:

Post a Comment