In this C++ programming tutorial we will talk some more about functions. We also will take a look at command-line parameters and function prototypes.
Command-line parameters
In some cases you want to give a parameter at the start of a program. For example: More »
Posted in C++ Tutorials |
Most languages allow you to create functions of some sort. Functions are used to break up large programs into named sections.
You have already been using a function which is the main function. Functions are often used when the same piece of code has to run multiple times. In this case you can put this piece of code in a function and give that function a name.
When the piece of code is required you just have to call the function by its name. (So you only have to type the piece of code once).
Let’s take a look at a simple example: More »
Posted in C++ Tutorials |
In this C++ programming tutorial we will look at loops.
There are circumstances were you want to do the same thing many times. For instance you want to
print the same words ten times. You could type ten cout statements, but it is easier to use a loop, such as a “for loop” or a “while loop.” The only thing you have to do is to setup a loop that execute the same cout statement ten times.
There are three basic types of loops which are: More »
Posted in C++ Tutorials |
In this C++ programming tutorial we take a look at the “if statement” and “switch statement”. Both are used to alter the flow of a program (if the specified test condition is true).
The if statement
The if statement can be used to test conditions so that we can alter the flow of a program. In other words: if a specific statement is true, execute some instructions. If not true, execute these instructions. More »
Posted in C++ Tutorials |
In this tutorial we take a look at standard I/O and strings. The string statements used in this tutorial are basic. Later on we will take another look at strings. (We first need to explain some other topics like: control loops, pointers, etc).
cin and strings
In the last tutorial we already covered the use of cin and cout. Let’s take another look at a cin and cout example: More »
Posted in C++ Tutorials |
In this tutorial we will take a look at basic input and output. Using the C++ iostream library we will get the user’s input from the keyboard and we will print messages onto the screen. The iostream library is part of the C++ standard library.
In C++, I/O is performed by using streams. A stream is a “stream of data” in which character sequences are “flow into” or “flow out off.” A stream is an object with properties that are defined by a class. Global objects are predefined for the standard I/O channels. More »
Posted in C++ Tutorials |
Now we know how to use variables and constants, we can begin to use them with operators. Operators are integrated in the C++ language. The C++ operators are mostly made out of signs (some language use keywords instead.)
Assignment
We used this operator before and it should already be known to you. For the people that didn’t read the previous tutorials we will give a short description. More »
Posted in C++ Tutorials |
In this tutorial we will take a look at constants and escape codes. We will also introduce strings.
Constants
The difference between variables and constants is that variables can change their value at any time but constants can never change their value. (The constants value is locked for the duration of the program.)
Constants can be very useful, PI for instance is a good example to declare as a constant. More »
Posted in C++ Tutorials |
In this C++ programming tutorial we take a look at variables and data types.
Variables
If you declare a variable in C++ (later on we will talk about how to do this), you ask the operating system for
a piece of memory. You (can) give this piece of memory a name and you can store something in that piece of memory (for later use). More »
Posted in C++ Tutorials |
We start the tutorial series with one of the simplest programs that can be written in the C++ language. More »
Posted in C++ Tutorials |