#include <iostream>
using namespace std;
int main() {
int integerNumber = 10;
float floatNumber = static_cast<float>(integerNumber);
cout << "Integer Number: " << integerNumber << endl;
cout << "Float Number: " << floatNumber << endl;
return 0;
}
- Include necessary header files.
- Declare the main function.
- Define an integer variable
integerNumber
and initialize it with the value 10. - Declare a float variable
floatNumber
. - Use
static_cast<float>
to convert integerNumber
to a float type and assign the result to floatNumber
. - Display the original integer value and the converted float value using
cout
. - Return 0 to indicate successful execution.