CS Department C++ Problem Solving

 

Before you begin coding, you must understand the problem. You need to break it down sufficiently in your mind so that you can tackle the program, especially when you are dealing with many different problems all in one program.

Once you understand what is needed, you must ensure you understand HOW to perform the kinds of calculations or manipulations necessary to get the correct solution.

This is usually done by writing an algorithm. Your algorithm is generally written in pseudo-code; some statements may be code, other statements may be English phrases, but it is precise and each and every step is indicated.

Your algorithm may begin as just a list of variables that you need. From there it progresses and grows until you have a complete list of instructions that are required to solve the problem!

After you have a complete algorithm, you can transform your pseudocode into whichever programming language you choose. In these examples, we are using C++ (see C++ Syntax).

Example 1 - All of the code resides in the main method - a very basic C++ program.
 
Example 2 - An example that makes use of functions.
 
Example 3 - Using classes

You are visitor #  .



Last modified: Friday, 21-Aug-2020 15:28:15 CST
Copyright 2000 Department of Computer Science, University of Regina.

CS Dept Home Page

Teaching Material