I have a question here
How I want to convert an int to float in the middle of the program
using namespace std;
is this line correct y= (float)x;?
Yes, it is correct.
Any suitable types could be converted using such "type cast" operator which looks like type name inside parentheses.
However, int needs not to be converted to float manually since it would be done automatically on assignment.
y = x;
x = (int) y;
Last edited on