C++ Exercises
Exercises
Test your C++ skills with exercises from all categories:
Syntax
Statements
Output Text
Output Numbers
New Lines
Comments
Variables
Multiple Variables
Identifiers
Constants
User Input
Data Types
Numeric Data Types
Boolean Data Types
Character Data Types
String Data Types
Arithmetic Operators
Assignment Operators
Comparison Operators
Logical Operators
Strings
String Concatenation
Numbers and Strings
String Length
Access Strings
Special Characters
User Input Strings
String Namespace
C-Style Strings
Math
Booleans
Boolean Expressions
If
Else
Else If
Short Hand If Else
Switch
While Loop
Do/While Loop
For Loop
Nested Loops
The foreach Loop
Break and Continue
Arrays
Arrays and Loops
Omit Array Size
Get Array Size
Multi-Dimensional Arrays
Structures
Enums
References
Memory Address
Pointers
Dereference
Modify Pointers
Functions
Function Parameters
Default Parameters
Multiple Parameters
Return Values
Pass By Reference
Pass Arrays
Function Overloading
Scope
Recursion
OOP
Classes and Objects
Class Methods
Constructors
Access Specifiers
Encapsulation
Inheritance
Multilevel Inheritance
Multiple Inheritance
Inheritance Access
Polymorphism
Files
Exceptions
Date
Data Structures and STL
Vectors
List
Stacks
Queues
Deque
Sets
Maps
Iterators
Algorithms
Log in to track your progress
If you haven't already, sign up to become a W3Schooler, and get points for every exercise you complete.
As a logged-in W3Schools user you will have access to many features like having your own web page, track your learning progress, receive personal guided paths, and more.
The Exercise
The exercises are a mix of "multiple choice" and "fill in the blanks" questions. There are between 3 and 9 questions in each category. The answer can be found in the corresponding tutorial chapter. If you're stuck, or answer wrong, you can try again or hit the "Show Answer" button to see the correct answer.