int int1, int2, int3; float float1, float2, float3; cout << 3 + 4; // both a are integer so the result is integer. cout << "hello" + " world"; // both are string ... int1 = int2 - int3; int1 = int2 / int3; float1 = float2 * float3;
int average, points, totalPoints; ... average = points / totalPoints * 100;
float y; long double x; y = float(4); // is ok x = long double(3); // is not ok.
float y; long double x; y = static_cast<float>(4); x = static_cast<long double>(3);
int result; result = static_cast<int>(4.999);
int result; result = static_cast<int>(4.999 + 0.5);