Playground
#include <iostream> using namespace std; int main() { double pi = 3.14; int a = (int) pi; int b = int(pi); int c = static_cast<int>(pi); cout << "a=" << a << endl; //pechati 'a=3' cout << "b=" << b << endl; //pechati 'b=3' cout << "c=" << c << endl; //pechati 'c=3' int i = 1; double d = (double)i; double e = double(i); double f = static_cast<double>(i); cout << "d=" << d << endl; //pechati 'd=1' cout << "e=" << e << endl; //pechati 'e=1' cout << "f=" << f << endl; //pechati 'f=1' return 0; }
Input data
Program output
no input
Execute
Language: ????????? | Memory: ???? KB | Time: ??? ms
Nothing has been executed, yet!