-
Notifications
You must be signed in to change notification settings - Fork 0
/
typecast.cpp
32 lines (29 loc) · 1.3 KB
/
typecast.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
using std::cout;
using std::endl;
int main() {
cout << "'a' = " << 'a' << endl;
cout << "char(97) = " << char(97) << endl;
cout << "'a'+5 = " << 'a'+5 << endl;
cout << "char(97)+5 = " << char(97)+5 << endl;
cout << "char('a'+5) = " << char('a'+5) << endl;
cout << "char(char(97)+5) = " << char(char(97)+5) << endl;
cout << "char(97)+char(5) = " << char(97)+char(5) << endl;
cout << endl;
cout << "int('a') = " << int('a') << endl;
cout << "double('a') = " << double('a') << endl;
cout << "int(97) = " << int(97) << endl;
cout << "double(97) = " << double(97) << endl;
cout << "int(5.7) = " << int(5.7) << endl;
cout << "double(5.7) = " << double(5.7) << endl;
cout << "char(98) = " << char(98) << endl;
cout << "char(98.6) = " << char(98.6) << endl;
cout << endl;
cout << "1/2 = " << 1/2 << endl;
cout << "1/2.0 = " << 1/2.0 << endl;
cout << "2147483647 + 10 = " << 2147483647 + 10 << endl;
cout << "2147483647 + 10L = " << 2147483647 + 10L << endl;
cout << "long(2147483647 + 10) = " << long(2147483647 + 10) << endl;
cout << "long(2147483647) + 10 = " << long(2147483647) + 10 << endl;
return 0; // success
}