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 (" ").
Printing a Number
Below is a simple example that outputs a numeric value:
#include <iostream>
using namespace std;
int main() {
cout << 1000;
return 0;
}
Output: 1000
Performing Mathematical Operations
C++ allows you to perform calculations directly within a cout statement.
Example: Addition
cout << 250 + 750;
Output: 1000
Example: Multiplication
cout << 20 * 50;
Output: 1000
Since numbers are not enclosed in quotes, the compiler treats them as mathematical expressions rather than text, performing calculations automatically.


