#05:数値を扱う
ここでは、プログラムで扱う数値データを扱う方法について学習します。また、これまで扱ってきた文字列との違いについて取りあげます。
数値として扱うには、ダブルクォーテーションなしで記述します。
#include <iostream>
using namespace std;
int main() {
cout << "Hello world" << endl;
cout << 100;
}
// 100
#include <iostream>
using namespace std;
int main() {
cout << "Hello world" << endl;
cout << 100 + 30;
}
// 130
#include <iostream>
using namespace std;
int main() {
cout << "Hello world" << endl;
cout << 100 + 30 << "円";
}
// 130円
#include <iostream>
using namespace std;
int main() {
cout << "Hello world" << endl;
cout << "100 + 30";
}
// 100 + 30