Horje
C++ Type Casting Code Example
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;
c++ cast to type of variable
x = static_cast<decltype(x)>(y);
type casting in cpp
int main()
{
	int a=20 , b= 25 , c= 19;
  	int sum = a + b + c;
  	float ave = (float) sum / 3;  //this is called type casting (float) sum 
  	cout<<"Average is : "<<ave<<endl;
  	return 0;
}
casting cpp
casting




Cpp

Related
c++ convert binary string to decimal Code Example c++ convert binary string to decimal Code Example
make cin cout faster Code Example make cin cout faster Code Example
string hex to int c++ Code Example string hex to int c++ Code Example
how to convert qt string to string Code Example how to convert qt string to string Code Example
how to check string contains char in c++ Code Example how to check string contains char in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11