Hello everyone, I'm new to the forums and I have recently just got into studying C++ a month ago and I've been looking for some mini exercises to help practice what I've studied so far. The tutorials are very helpful but it does not seem to provide any tasks to perform after each chapter to practice the stuff you've just learned.
I've learnt all the basics:
Structure of a program
Variables and types
Try this (question made on my own):
A triangular number is generated by the following formula (n^2+n)/2. Make a program which takes in a limit from the user and sums up all the triangular numbers till that limit. Then display the result to the user.
1) Format your code nicely, commenting what each line does (this does help you learn)
2) Show the user a prompt like "Enter a limit: " and "Result: ".
3) Try to use meaningful variable names
Post your code when you are done and I'll check it tomorrow ;) (Its 10:38 PM here).
A simple game is the best exercise because it's all programming logic and doesn't require you to solve a Math problem before you can start coding.
The key is to learn how to structure your code for optimal readability and reusability and Games are perfect for that.
So start with something simple like a Mad Libs games and then try to move on to something a bit more involved such a board based game where you can familiarize yourself with 2D arrays such as Battleship, Checkers, or even Chess.
I found that math puzzles from [url]projecteuler.net[/url] helped me learn to think like a programmer and helped especially with algorithmic thinking. You will want to know about iteration (for, while, do while) and selection (if, switch) for that.