ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662
Original Poster
Rep:
I badly need your help your help to find the fault in the following program.
1. The name of the program is 'temp100'.
2. After the compilation, I want to create a program called 'temp250'.
------------------------------------------------------
#include <iostream>
using namespace std;
long factorial (long a)
{
if (a > 1)
return (a * factorial (a-1));
else
return (1);
}
int main ()
{
long number;
cout << "Please type a number: ";
cin >> number;
cout << number << "! = " << factorial (number);
return 0;
-----------------------------------------------------
However, I got the following error message:
[root@c83-250-99-43 Shell Scripting]# g++ 'temp100.cpp' -o temp250
temp100.cpp: In function ‘int main()’:
temp100.cpp:21: error: expected `}' at end of input
[root@c83-250-99-43 Shell Scripting]#
What is the problem?
1. It may be factorial function is not in the 'iostream' library.
2. I have heard that some functions are missing in some versions.
3. For example, Borland compiler is different from Dev C++ compiler.
I appreciate your help for fixing the problem in the above program.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.