The Beginning

Pages: 12
closed account (G854izwU)
Hello guys! I am new to this forum and would like to start off by saying hello to all of you! I have wanted to start learning C++ for a while now but I have never found a way to get on my feet when programming C++. I need to find a way to learn C++. I have a lot of free time so I can practice a lot. I have a background in programming and I know the very basics. I learn by doing I need to be given exercises and figure out the problems with minimal hints. I don't learn by just reading a book or listening to a lecture I need to be hands on with it and implement what I learned.

I was wondering if any of you know a good way to get started in C++. How did you guys get started? What are your stories? Do you have an links to tutorials that will benefit me? One thing I don't like though is when you follow a tutorial on the internet and you learn something then the next day you find out that what you learned was the wrong way to do it. Well any help would be greatly appreciated. Thank you all for your time.

-TheNewKid-
Be very suspicious of any source that has void main() in it. Don't listen to Herb Schildt.

Read this:
http://www.cplusplus.com/doc/tutorial/

and start coding.

The most common mistake I see newcomers make is thinking that programming is about the syntax. It's not. It's really, really not. It's being able to understand a problem and think about it in a way that lends itself to a computational answer with the tools available (i.e. solving it in a way that you can then program it). A good place to start on practice problems is Project Euler, which will force you to actually think about how to solve problems.

http://www.projecteuler.net
Last edited on
closed account (G854izwU)
Thank you so much! These links look they will help a lot. Anyone else have anything to go along with what Moschops said?

-TheNewKid-
What's wrong with Herbert Schildt?

His beginner's guide is quite good. I think so at least, i'm reading it now ;D
most beginners find video tutorials easier than books, have a look on youtube for spoonfed c++ tutorials, or buckys c++ tutorials, both are long enough for you to learn the basic core of c++.
closed account (G854izwU)
@Moschops or anyone else who would like to help. I went to project euler and to problem number 1. I understand that when you become a programmer its not about learning a programming language because anyone can do that its about they way you think. You have to dive into the problem you are faced with looking for a way to get to the answer not the answer itself. You need to be able to think logically and sequentially. The computer and the program is just a tool to help you get to the answer the real work is the journey to the answer. But back to what I need help with. So I was doing the first problem and the problem is Find the sum of all the multiples of 3 and 5 below 1000. So I got out my trusty pad of legal paper and got to work writing out a solution. When I got what I thought would work and I created the program. Here is the code.

Edit: source code deleted to prevent cheating.

I replaced the 1000's with 10's because that was easy enough for me to figure the answer out in my head. The program came up with 23 and so did I so I thought great! So I changed the 10's back to 1000's ran the program and I got 266333 and I thought awesome. So I went to the problem on the website typed in my answer and it said it was incorrect! How can that be when it worked for 10? Any help would be great. Thanks!

-TheNewKid-
Last edited on
30 is a multiple of 3.
30 is also a multiple of 5.

Should it really be included twice?

How would you go about removing any multiples of both 3 & 5?
closed account (G854izwU)
Your a genius! Hold on let me think about it for a few minutes and work it out then I will post back. =D

-TheNewKid-
What's wrong with Herbert Schildt?



For starters, for a very long time his books insisted void main() was fine.

Do a google search - you'll find lots of complaints people have. Unfortunately, his writing style is easy to understand, and since his books are aimed at beginners, they don't realise what they're being taught.
Last edited on
I don't even remember my first book anymore, it was for some high school C++ class I took. I ended up reading the whole book outside of class (the class only made it to chapter 6), but it was a decent book. As far as I remember it wasn't teaching any bad practices, and definitely got me into the language. But I think the sure fire way to learn is to just code, make mistakes, many mistakes, and learn from those mistakes. I've learned more from breaking programs than I have from making solid programs right off the bat. Just recently I was making a renderer(spelling?) and forgot to actually allocate some memory before I called it to be de-allocated. Needless to say, I ran into some odd issues and about crashed my computer.
closed account (G854izwU)
Can any of you guys help me figure out how to find the last digit of an int value? Thanks!

-TheNewKid-
Can any of you guys help me figure out how to find the last digit of an int value?

You're gonna need to look into the modulus operator, if you haven't already had experience with it. See if you can figure out how it applies.
closed account (G854izwU)
Thank you! Ill look into it right now. And you guys are fast!
closed account (zb0S216C)
TheNewKid wrote:
Can any of you guys help me figure out how to find the last digit of an int value?

Here's a list of built-in types and their ranges: http://www.cplusplus.com/reference/clibrary/climits/

Wazzak
Yup no problem
closed account (G854izwU)
Thanks guys! I got problem one =D Heres the code I used.

Edit: Source code deleted to prevent cheating.

I wasn't sure if I needed to include cmath for the modulus operator or not so I did just to be safe. Now I'm on to problem to.
Last edited on
Nope you don't need cmath for modulus, but it's a good header to get used to none the less :D
closed account (G854izwU)
Hey guys I was wondering if there was a way to compare a number to a whole array? Like if x == somearray So that it compares x to all the values in the array. Thanks!

-TheNewKid-
You would have to loop through the array and compare x to each of the values.
closed account (G854izwU)
Thank you guys so much for getting me started! I really want to learn C++ and this is a great start. I will continue more tomorrow and I might need your help again but thank you all!

Also I have completed problems 1 & 2 on project euler. I also am going to delete the source code for problem one above so others can't cheat off of mine.

-TheNewKid-
Pages: 12