// cast.cpp -- experiments with casting and conversion #include void main(void) { int x = 7; char c = 'A'; cout << "x = " << x << endl; cout << "(float)x = " << (float)x << endl; cout << "float(x) = " << float(x) << endl; cout << "c = " << c << endl; cout << "(int)c = " << (int)c << endl; cout << "int(c) = " << int(c) << endl; cout << "((float)x)/2 = " << ((float)x)/2 << endl; cout << "float(x)/2 = " << float(x)/2 << endl; } /* The output is: x = 7 (float)x = 7 float(x) = 7 c = A (int)c = 65 int(c) = 65 ((float)x)/2 = 3.5 float(x)/2 = 3.5 */