Hello.....
Where I am wrong in this program.
I am getting declaration syntax error.

#include<iostream.h>
#include<conio.h>
int factorial(int)
int main()
{clrscr();
int n,r,nr,fn,fr,fnr;
int ncr;
cout<<"/n Enter n and r = ";
cin>>n>>r;
fn=factorial(n);
fr=factorial(r);
nr=n-r;
fnr=factorial(nr);
ncr=fn/(fr*fnr);
cout<<"/n nCr ="<<n<<" C "<<r<<" = "<<ncr<<endl;
getch();
return 0;
}

Thanx

Are you using Turbo C++ format??? The #include<iostream> should not have .h in there. The same applies to the next line.

PS: Next time, please include the exact ERROR MESSAGE you saw from your compiling process...

Thanx for reply Tayin.

I am using Turbo C++.
When I run this program it says declaration syntax error.
When I compiled this turbo c++ says "compile successfully"
It shows error message on running this program....

You have to define factorial() function and don't use old turboc compiler. Here you can find name of some compilers.

#include<iostream>

int factorial(int);  // function declaration

int factorial(int value)  //function definition
{
   //code
}
int main() 
{
  //code
}

Hey.
I had the same problem with me. The program was fine. When I saved the program with .C extension, it showed my the declaration syntax error but when I saved the program with .CPP extenion, it worked fine.

Regards,
Paras

I'm currently having the same problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.