(Checking in Ascending Order)
#include<iostream.h>
#include<conio.h>
void main()
{
int fact = 1, no, i;
clrscr();
cout<<"Enter a number :";
cin>>no;
for(i = 1; i <= no; i++)
{
fact = fact * i;
}
cout<<"The factorial of number is :"<<fact;
}
(Checking in Descending Order)
#include<iostream.h>
#include<conio.h>
void main()
{
int fact = 1, no, i;
clrscr();
cout<<"Enter a number :";
cin>>no;
for(i = no; i >= 1; i--)
{
fact = fact * i;
}
cout<<"The factorial of number is :"<<fact;
}
#include<iostream.h>
#include<conio.h>
void main()
{
int fact = 1, no, i;
clrscr();
cout<<"Enter a number :";
cin>>no;
for(i = 1; i <= no; i++)
{
fact = fact * i;
}
cout<<"The factorial of number is :"<<fact;
}
(Checking in Descending Order)
#include<iostream.h>
#include<conio.h>
void main()
{
int fact = 1, no, i;
clrscr();
cout<<"Enter a number :";
cin>>no;
for(i = no; i >= 1; i--)
{
fact = fact * i;
}
cout<<"The factorial of number is :"<<fact;
}