#include<iostream.h>
#include<conio.h>
int factorial(longint);
void main()
{
clrscr();
longint a;
cout<<"This program displays the factorial of the number you enter."<<endl;
cout<<"Enter the number: ";
cin>>a;
cout<<"The factorial of the number you entered is: "<<factorial(a);
getch();
}
int factorial(longint x)
{
longint p=1;
for(int i=x; i>0;i--)
p*=i;
return p;
}
1. <iostream.h> is deprecated, you need to use <iostream> without .h
2. <conio.h> is non-standard
3. The function prototype on line 3 takes no parameters, you call it on line 11 with one parameters, and you define an unrelated function with the same name on line 14
But I guess its c++turbo...I entered the <iostream> file but then it says.."could not open the file iostream"..maybe then there is something wrong with that...and ok the program runs on editing line 3 but it doesnt give the output even then :| ..thanks for your help till now :)
Then I'm very very sorry for you, you'll just have to suffer through your assignments writing deprecated code until you complete the course and will be able to use modern C++ :(
As for your code, don't you think you should return p and not i which no longer exists?