C++ Program to display factorial of a number.

How to display factorial of a number in C++ programming ?

C++ Program to display factorial of a number.Program to find factorial of Number in C++ c++ program to find factorial of a number c++ program to find factorial of a number using class c++ program to find factorial of a number using function c++ program to find factorial of a number using constructor c++ program to find factorial of a number using inline function c++ program to find factorial of a number using recursion c++ program to find factorial of a number using while loop write a c++ program to find the factorial of a number
C++ Program to display factorial of a number.

Solution:
//Program to display factorial of a number.
#include<iostream.h>
#include<conio.h>
fac(int);
void main()
{
clrscr();
int a;
char z;
do
{
cout<<"Enter a number: ";
cin>>a;
a=fac(a);
cout<<"The factorial is: "<<a<<endl;
cout<<"Do you wish to display another factorial? (y/n): ";
cin>>z;
}
while(z=='y'||z=='Y');
}

fac(int a)
{
int i,b;
for(i=1,b=1;i<=a;i++)
b=b*i;
return b;
}

This C++ Program display factorial of a number.


Learn More :