In C++, the times operator (*) is used for multiplication. Here are some examples to illustrate how to use times in C++:
Example 1: Simple multiplication
int x = 5;
int y = 10;
int z = x * y; // z will have the value 50
Example 2: Multiplying decimal values
double x = 3.5;
double y = 2.25;
double z = x * y; // z will have the value 7.875
Example 3: Multiplying variables and constants
const int PI = 3.14; // constant value of PI
int radius = 5;
double area = PI * radius * radius; // area will have the value 78.5
Example 4: Using times for loops
for (int i = 1; i <= 10; i++) {
int result = i * 3; // result will have the values 3, 6, 9, 12, 15, 18, 21, 24, 27, 30
}
Overall, the times operator (*) is a simple yet powerful operator that is commonly used for performing arithmetic multiplication in C++.