Type casting

Hello guys, I have so much confusion about typecasting, for example, look at the code below:

#include <bits/stdc++.h>

using namespace std;

int main()

{

float c = 5.0;

int x = 1;

cout << x * c;

return 0;

}

it results in 5 not 5.0 but why? As we are performing an operation with a float so the answer should in float only?

I think if the result is a whole number then there will be no decimal point.

Use setprecision to get the desired precision.

I think you need to change the cast system decimal into int .

here is the thing . in most of the languages compiler automatically imlicilty cast the types as you are multiplying integer with float so compiler will automat tha cast type to integer of the whole answer.
solution :
float c = 5.0;

float x = 1;
cout << x*c ;