C++ for Beginners Video Series
Welcome to the companion website to the C++ for Beginners video series on YouTube.
This site will contain material to supplement the videos and help you learn to program in C++.
For an overview of the CodeBlocks installation process and a few other setup tips/tricks, refer to:
Initial Setup of Code Blocks IDE
Compile Programs from the Windows Command Line
Video Playlist
The latest videos each have their own separate companion page:
Video 10 - Multidimensional Arrays and Introduction to Vectors
Video 08 - Menu Program and Switch Statement
The rest of the series is listed below for now.
Lesson 1 - Hello World
The first video covers downloading, installing, and using the Code::Blocks IDE.
We then go over the simple Hello World program automatically generated by the IDE, as shown below:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
Lesson 2 - Improved Hello World
Lesson 2.1 - Improved Hello World (part 2)
Lesson 3 - Variables and Functions
Logical Operators: && AND, || OR, ! NOT
Assignment Operators: "=" assigns the value on the right to the variable on the left. Ex: int a = 10;
There are also +=. -=, *=, /=, and %= assignment operators.
int a = 5;
a += 5; // a is now equal to 10, this operator adds 5 to a's original value then assigns the new sum back to 'a'.
int b = 10;
b -= 5; // b is now equal to 5, this operator subtracts 5 from b's original value then assigns the result back to 'b'.
int c = 5;
c *= 5; // c is now equal to 25, this operator multiplies 5 to c's original value then assigns the result back to 'c'.
Functions:
Declaration: the functions name, return type, and parameters (if any). Definition: the body of the function (code to be executed).
Functions are declared in the format:
return-type functionName(parameters)
Function Declaration Example:
int myFunction(param1, param 2)
- returns an int, name is myFunction, and accepts two parameters.
Variable Declaration: int a;
Creates a variable named 'a' that is of type int (integer).
Variable Initialization: a = 22;
Previously declared variable 'a' is assigned the value of '22'.
Variable Declaration and Initialization: float pi = 3.14159;
Creates a new variable of the float type named pi and is assigned the value 3.14159
The 'if' statement is used to execute a block of C++ code if a condition evaluates to true.