//Header files
#include<iostream.h>
#include<conio.h>
//Main function
void main()
{
int num,i;
long factorial=1;
//Function for clearing screen
clrscr();
cout<< "Enter a number:";
cin>>num;
//using if-else conditonal statements
if(num<0)
{
cout<<"Error! Factorial of a negative number does not exist";
}
else
{
for(i=1;i<=num;i++)
{
factorial=factorial*i;
}
cout<<"Factorial of the given number:"<<factorial;
}
//Function for holding screen
getch();
}