C++ | The School of Code

Settings

Appearance

Choose a typography theme that suits your style

C++

Learn systems programming with C++.

1

Hello World

C++ uses cout for output. Include <iostream> header and use the std namespace.

Example

Run this example to see how it works and then try the exercise.

example.cpp
Loading...
Output
Click "Run" to see the example in action...
Exercise

Your task: Use cout to print "Hello, World!"

main.cpp
Loading...
Output
Click "Run" to execute your code...
Quiz

Which operator is used with cout to output data?

SUMMARY

In this section, you learned how to print output to the console. Next, you'll learn how to declare variables and work with different data types.

2

Variables and Data Types

C++ is statically typed - you must declare the type before using a variable.

Example

Run this example to see how it works and then try the exercise.

example.cpp
Loading...
Output
Click "Run" to see the example in action...
Exercise

Your task: Declare variables: name (string), age (int)

main.cpp
Loading...
Output
Click "Run" to execute your code...
Quiz

What does "statically typed" mean in C++?

SUMMARY

In this section, you learned how to declare variables and work with different data types. Next, you'll learn how to get user input from the console.

3

Arithmetic Operations

C++ supports all standard arithmetic operations. Integer division truncates the decimal part.

Example

Run this example to see how it works and then try the exercise.

example.cpp
Loading...
Output
Click "Run" to see the example in action...
Exercise

Your task: Calculate area and print "Area: {area}"

main.cpp
Loading...
Output
Click "Run" to execute your code...
Quiz

What is the result of 17 / 5 in C++ (both are int)?

SUMMARY

In this section, you learned how to get user input from the console. Next, you'll learn how to perform mathematical operations.

Unlock 10 More Lessons

You've completed the free preview! Upgrade to Pro to access all 12 lessons in this course, plus advanced projects and certificates.

Locked lessons:
  • String Operations
  • Conditionals
  • For Loops
  • For Loops
  • While Loops
  • Functions
  • Vectors
  • Classes and Objects
  • Final Project: Student Grade System
Hello World 1
Variables and Data Types 2
Arithmetic Operations 3
Unlock 10 more lessons Access all content with Pro
Upgrade
String Operations 4 Conditionals 5 For Loops 6 For Loops 7 While Loops 8 Functions 9 Vectors 10 Classes and Objects 11 Final Project: Student Grade System 12

Reset Progress?

Are you sure you want to reset all progress for this course? This action cannot be undone.