C++ Print Numbers

Just like text, numbers can also be displayed using the cout object. However, the key difference is that numbers do not need to be enclosed in double quotes (" ").

Tutorials dojo strip



Printing a Number

Below is a simple example that outputs a numeric value:

C++

Output: 1000




Performing Mathematical Operations

C++ allows you to perform calculations directly within a cout statement.

Example: Addition

C++

Output: 1000

Example: Multiplication

C++

Output: 1000

Since numbers are not enclosed in quotes, the compiler treats them as mathematical expressions rather than text, performing calculations automatically.

Tutorials dojo strip