Unit 1: Introduction and Setup
This unit presents a brief history of C++ before addressing the mechanics of editing and compiling simple programs in C++ using the Eclipse IDE (integrated development environment). We will focus on how to write and format a general C++ program, the meaning
of the main()
function, how to use the cout
and cin
objects, how to declare and use variables, and how to use arithmetic operators.
Completing this unit should take you approximately 8 hours.
Upon successful completion of this unit, you will be able to:
- describe the basic history of C++;
- set up and create a simple C++ project using Eclipse CDT;
- explain the meaning of simple C++ commands;
- use cout and cin objects effectively;
- declare and use variables; and
- use C++ operators.
1.1: A Basic History of C++
Watch this video for a broad overview of the history of computer programming in general.
Read this article on the history of C++ programming to see how C++ evolved into what it is today.
1.2: How to Compile and Run a C++ Program
If you are running a Linux operating system, read this article on how to compile and run a C++ program. Even though you do not yet understand the C++ language, you can follow the operational steps to compile a program from C++ to machine code.
Watch this video to learn how to install the Eclipse CDT.
For the programming in this course, we will use the Eclipse CDT. In order to follow these steps, you need to first install Eclipse. You can go to https://www.eclipse.org/downloads/ to download the Eclipse software, which then prepares you for write Java code. However, we want to write code in C++ instead of Java, so we have to take a few additional steps that are different depending on your operating system. Those steps are described in this article.
After you watch this video, try to create, compile, and run your own Hello World program.
1.3: Simple C++ Commands
After you read this article, compile the example and make sure you understand the code in each line.
1.4: Variables, Data Types, and Constants
Read this article about data types. Although this article discusses C, the data types in C++ are exactly the same. The only difference is that C does not include a boolean variable. For now, just note that a boolean variable holds a value of either True or False.
Watch this video, which explains how data types are used in C++.
1.5: Basic Input and Output
Watch this (admittedly robotic) video, which explains input and output.
1.6: Arithmetic Operators
We touched on operators in the previous unit, but now we will cover them in more detail. Even though this is C and not C++, there are no major differences in their operators.
Watch this video, which discusses the use of arithmetic operators and their real world applications.
Unit 1 Exercises
Exercises 1 to 36 cover basic C++ concepts that you should be able to complete if you have worked through all of the materials in unit 1. Start with some early problems, then try a few from the middle, and then a few more later from the list. Do not attempt any of the problems after Exercise 36, as we haven't learned these concepts yet. Don't worry, we will come back to them.
- Complete these exercises to check your understanding of input and output.