C++#002_Variables

第2話変数を定義するとき使う予約語をメモします。

int :整数

double :実数

char :文字

string :文字列

ちなみにendlは改行です。

Example

#include <iostream>
using namespace std;


int main(){

    int i32=110;
    double r64=43.2;
    char myChar=’C’;
    string myText=”Hello :)!”;
    bool bSw=false;

    cout << i32 << endl;
    cout << r64 << endl;
    cout << myChar << endl;
    cout << myText << endl;
    cout << bSw     << endl;

    //Define multiple values
    int x=10,y=20,z=30;
    cout << x+y+z << endl;

    //Define Constant
    const   float pi =3.14;
    cout << pi <<endl;

}

シェアする

  • このエントリーをはてなブックマークに追加

フォローする