I have 2 numbers num1=251 and num2=45. I have to divide 251/45 and the answer has to be a double. How do I static cast this so it turns out to be a double?
I cast num1 to a double but the answer still comes out as an int and it says: " warning C4244: '=' : conversion from 'double' to 'int', possible loss of data"
int num1 = 251, num2 =45;
std::cout<<(double)num1/num2;
this gives you 5.7777778 which is the correct answer.
Maybe your storing the result of num1/num2 in some variable that is an int? That would give you an int result of 5 and not a double