First day of learning C++, coded this little program to have a basic understanding of basic i/o and the new data types, e.g. the bool type. 第一天编写该小程序以基本了解基本输入输出,还有新数据类型bool。
Code for basic input and output:
#include <iostream> #include <stdlib.h> using namespace std; int main(void) { cout << "Please enter an integer:" << endl; int x = 0; cin >> x; cout << oct << x << endl; cout << dec << x << endl; cout << hex << x << endl; cout << "Please enter a boolean number(1 or 0):" << endl; bool y = false; cin >> y; cout << boolalpha << y << endl; system("pause"); return 0; }Please enter an integer: 10 12 10 a Please enter a boolean number(1 or 0): 1 true 请按任意键继续…