Programming Fundamentals · Lesson 09
Introduction to C++
Meet C++, read your first complete program, and understand how source code becomes a running program.
C++ is a programming language used to build applications, games, and other software. You write instructions in a source file, commonly ending in .cpp. A compiler checks and translates that source, and a linker combines the compiled parts into a program you can run.
This lesson uses a small console program: its output is text. Read it from the top and find the message in quotation marks. You can follow the example and take the quiz without installing anything.
To try it on Windows, install Visual Studio with the Desktop development with C++ workload. Create a C++ Console App, replace its starter code with the example below, and build and run it. A text editor by itself cannot compile C++. The official setup walkthrough is linked below.
Read the example
#include <iostream>
int main() {
std::cout << "Hello, PAMS!" << '\n';
return 0;
}
Hello, PAMS!
#include <iostream> makes the standard input/output declarations available. Our console program begins executing at main(). The braces { and } enclose its body.
std::cout sends output to the console. The << operators insert the message and then a newline character, '\n'. Double quotes surround a string; single quotes surround a character. The std:: prefix names the standard-library namespace.
The semicolon ends each statement in this example. return 0; reports successful completion. C++ distinguishes uppercase and lowercase letters: main and Main are different names.
A compile error prevents this program from building, such as a missing semicolon. A logic error can produce a running program with the wrong result. After editing the source, rebuild it to run the new version.
Try it yourself
Change the message to "I am learning C++." Add a second output statement that displays "My first step with PAMS." on the next line. Predict both output lines before you rebuild and run.
Show a worked solution
#include <iostream>
int main() {
std::cout << "I am learning C++." << '\n';
std::cout << "My first step with PAMS." << '\n';
return 0;
}
Further reading
Check your understanding
Your lesson quiz
Answer all five questions. Score at least 4 out of 5 (80%) to pass. You can retry as often as you like.
Quiz progress is saved in this browser. View certificates →
Learn together
Was this lesson helpful?
Comments and reactions are not open yet.
Join the conversation
Ask a question or share what you learned. Your display name and comment will be public after review. Please leave out private information. How feedback is stored