C++ uses cout for output. Include <iostream> header and use the std namespace.
C++
Learn systems programming with C++.
Hello World
Run this example to see how it works and then try the exercise.
Click "Run" to see the example in action...Your task: Use cout to print "Hello, World!"
Click "Run" to execute your code...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.
Variables and Data Types
C++ is statically typed - you must declare the type before using a variable.
Run this example to see how it works and then try the exercise.
Click "Run" to see the example in action...Your task: Declare variables: name (string), age (int)
Click "Run" to execute your code...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.
Arithmetic Operations
C++ supports all standard arithmetic operations. Integer division truncates the decimal part.
Run this example to see how it works and then try the exercise.
Click "Run" to see the example in action...Your task: Calculate area and print "Area: {area}"
Click "Run" to execute your code...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.
- String Operations
- Conditionals
- For Loops
- For Loops
- While Loops
- Functions
- Vectors
- Classes and Objects
- Final Project: Student Grade System