How we can change one data type into another in c++ code


It is very easy to how we can change one data type into another. For this purpose we will use static cast statement. As you can see below general structure of static ast data type.

static_cast<data type in which we want to change>(data type which is change into another data type)

Know you can read code

Code:

#include <iostream>
using namespace std;
int main() {
 cout<<static_cast<int>(3.09);
}

Output:

3

Its mean that float data type change into int data type because 3.09 is a float number.

Click Here For Watching Video Of Given Code

avatar
AUTHOR: Muhammad Abbas
I am Software Engineer.

0 Comments