Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

C++ Type Casting

    float a = 10.3;
    int b;
    char c = 's'; //115 in ASCII

    //USING IMPLICIT TYPECASTING
    b = a / 2; //where the value of 'a' turned into int value 
    cout << b << endl;
    cout << b + c << endl;

    //USING EXPLICIT TYPECASTING
    cout << (int) a + 8 << endl;
 
PREVIOUS NEXT
Tagged: #Type #Casting
ADD COMMENT
Topic
Name
4+7 =