0

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

4
Contributors
4
Replies
20
Views
2 Years
Discussion Span
Last Post by PARAS_1
0

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...

Edited by Taywin

-1

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....

0

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
}
0

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

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.