LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-10-2007, 12:29 PM   #31
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Original Poster
Rep: Reputation: 47

Thanks Nylex for your help.
I will try to run some C programs too when time permits.
 
Old 01-11-2007, 10:00 AM   #32
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Original Poster
Rep: Reputation: 47
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.
 
Old 01-11-2007, 10:08 AM   #33
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Like the error stated: You are missing a curly bracket.

Just below int main there is a curly bracket, the closing one is missing.
 
Old 01-11-2007, 10:20 AM   #34
Gins
Senior Member
 
Registered: Jul 2004
Location: Germany
Distribution: open SUSE 11.0, Fedora 7 and Mandriva 2007
Posts: 1,662

Original Poster
Rep: Reputation: 47
Thanks druuna
I am blind.
 
Old 01-11-2007, 12:13 PM   #35
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by Gins
Thanks druuna
I am blind.
That, too :}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A small problem Gins Programming 14 07-18-2006 07:57 AM
small c/c++ problem Garda Programming 16 05-24-2006 11:31 AM
A small problem in C indian Programming 2 09-07-2004 08:56 AM
small problem s9722 Linux - Newbie 4 06-05-2003 07:13 PM
this problem is so small destkid Linux - Newbie 3 10-19-2001 09:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration