#### Archived

This topic is now archived and is closed to further replies.

# Help! :)

## Recommended Posts

ThomasSauder    122
Error : C:\Documents and Settings\TJ\Desktop\Test Program\TestProgram.cpp(30) : error C2065: ''If'' : undeclared identifier C:\Documents and Settings\TJ\Desktop\Test Program\TestProgram.cpp(31) : error C2143: syntax error : missing '';'' before ''{'' C:\Documents and Settings\TJ\Desktop\Test Program\TestProgram.cpp(36) : error C2065: ''Else'' : undeclared identifier C:\Documents and Settings\TJ\Desktop\Test Program\TestProgram.cpp(36) : error C2146: syntax error : missing '';'' before identifier ''cout'' // This program asks for 3 numbers, gives them back, and asks the user if he wants to multiply // it by 5 #include <iostream> int main() { using namespace std; typedef unsigned long int ULONG; ULONG Number_1; ULONG Number_2; ULONG Number_3; ULONG Answer; ULONG Total; cout << "Please type in 3 numbers:" << endl; cout << "Number 1:" << endl; cin >> Number_1; cout << "Number 2:" << endl; cin >> Number_2; cout << "Number 3:" << endl; cin >> Number_3; cout << "The numbers you have entered were: " << Number_1 << Number_2 << Number_3; cout << "Would you like to multiply your answer by 5?" << endl; cout << "Press (1) for yes or (2) for no" << endl; cin >> Total; Answer = (Number_1 + Number_2 + Number_3) * 5; If (Total != ''2'') { cout << "All your Integers added together times 5 is: " << endl; cout << Answer << endl; } Else cout << "Well thank you for testing out my real basic program\n"; return 0; } That''s the code... I''m not sure why it won''t allow me to compile. How can IF be an unideclared identifier?

##### Share on other sites
micepick    122
Don't capitalize "if" or "else". No C++ keywords have upper case letters in them.

[edited by - micepick on October 2, 2002 9:03:00 PM]

##### Share on other sites
Don't listen to me...

[edited by - PepsiPlease on October 2, 2002 9:03:44 PM]

##### Share on other sites
Martee    476
C++ is case sensitive. Use if and else, not If and Else.

##### Share on other sites
ThomasSauder    122
Thanks so much!...

I would really appreciate it if they skipped the Visual Basic aspect of programming. I''m getting used to the non-case sensitive language of Basic.

I have a question. Is that a good C++ program for someone Who''s finished Chapter 4 of 21 in Sams Teach Yourself C++ in 21 Days?

Within these chapters I have learned:
1.What a function is and what it does
2.How the parts work together
3.How to Declare and Define variables and constants.
4.How to assign values to variables and manipulate those values
5.How to write the value of a variable to the screen
6.What statments are
7.What blocks are
8.What expressions are
9.How to branch your code based on conditions
10.What truth is, and how to act on it

That is what I have learned so far, I''m just wondering with that program, am I grasping what I have learned so far?
(btw I didn''t look at the book when i created this program)

Thanks

##### Share on other sites
micepick    122
Looks like you know what you''re doing fairly well. Here''s one problem, though:

If (Total != ''2'')

If Total is an unsigned long, you shouldn''t be comparing it to the character ''2''. You should be comparing it to the number two. The above code would not work correctly. Here is the right version:

if (Total != 2)

Another tip is to use better variable names than that. The name ''Total'' has nothing to do with the variable''s function, so it is somewhat confusing to a reader. That''s pretty much all I can think of right now...

##### Share on other sites
ThomasSauder    122
Thank you guys very much. I plan on reading around 5 C++ books to grasp it well enough to move onto windows.

But for now I hope I'm grasping everything

Awesome fast responses!!! Thanks!!

These books include:
Sams Teach Yourself C++ in 21 Days (I'm reading this now)
Teach Yourself C++ *By Shildt*
Accelerated C++
Effective C++
More Effective C++

Would this be a good choice of books?

[edited by - ThomasSauder on October 2, 2002 9:28:16 PM]

##### Share on other sites
micepick    122
Reading so many C++ books is a waste of time as far as I''m concerned. Limit yourself to one beginner book, and a couple of advanced ones. I personally like "The C++ Programming Language" by Bjarne Stroustrup (the original creator of C++). This book is not for beginners though, since it teaches advanced concepts of C++ at a very rapid pace. Some may not agree with me, but I found "Thinking in C++" by Bruce Eckel helpful as well (and besides, you can find it online for free).

Personally, I tend to want to see impressive results from my programs ASAP, so I don''t think it''s necessary to master C++ before moving on to Win32. Once you have a nice, firm grasp of the language, you should be able to pick up Windows and graphics API programming without too much trouble. Of course, you should work on your advanced C++ skills at the same time.

##### Share on other sites
Cyberdrek    100
quote:
Original post by ThomasSauder
Thanks so much!...

I would really appreciate it if they skipped the Visual Basic aspect of programming. I''m getting used to the non-case sensitive language of Basic.

I have a question. Is that a good C++ program for someone Who''s finished Chapter 4 of 21 in Sams Teach Yourself C++ in 21 Days?

Within these chapters I have learned:
1.What a function is and what it does
2.How the parts work together
3.How to Declare and Define variables and constants.
4.How to assign values to variables and manipulate those values
5.How to write the value of a variable to the screen
6.What statments are
7.What blocks are
8.What expressions are
9.How to branch your code based on conditions
10.What truth is, and how to act on it

That is what I have learned so far, I''m just wondering with that program, am I grasping what I have learned so far?
(btw I didn''t look at the book when i created this program)

Thanks

To answer the question simply, the code is good C++ but it''s flawed. They shouldn''t use "using namespace std", they should teach you to use scopes instead. It tends to make code easier to read...

[Cyberdrek | the last true sorcerer | Spirit Mage - mutedfaith.com]

##### Share on other sites
ThomasSauder    122
Isn''t The C++ Programming Language out of date? I heard it doesn''t even mention STL....

##### Share on other sites
prh99    520
quote:
Original post by ThomasSauder
Isn''t The C++ Programming Language out of date? I heard it doesn''t even mention STL....

It wouldn''t be hard to update C\C++.

##### Share on other sites
deepdene    292
The C++ Programming Language (The book) has gone through many revisions through the years, the 3rd edition (or the special edition based off that one) has all the latest ANSI C++ stuff including STL.

quote:
Original post by ThomasSauder
Isn't The C++ Programming Language out of date? I heard it doesn't even mention STL....

[edited by - deepdene on October 2, 2002 10:14:29 PM]

##### Share on other sites
ThomasSauder    122
Ok Thanks.... I''ll buy that one once I''m done both C++ books.... It''s only \$110 with tax Canadian so it''s not that bad. Affordable

Thanks everyone.

##### Share on other sites
ThomasSauder    122
The C++ Programming language book is free?

##### Share on other sites
ThomasSauder    122
The C++ Programming language book is free?