- 1
Why it's printing int value as it is float data type
7 Réponses
+ 11
Gireesh Desineni
In your code you declared A ,B ,C;
As int that's why it's output is in int.
If you want your output in float then you have to declare
float A,B,C;
+ 3
In your program variable A,B and C you defined int type but in( gain ) variable u defined float data type so after calculation it will give float values if u will define gain as a int like (int gain) then answer will give int value
+ 2
You can either change the values during declaration to be float or you can type cast the result to float
Line 9
float gain =(float)((C-A-B)*100)/(A+B);
0
XXX yeah but it is printing int value try with 4700
800 5800
0
Gireesh Desineni sorry, I misunderstood. It is because on the RHS you are dividing an int by an int which is also an int. Try changing A, B and C to float.
0
Input the numbers with a decimal point in them. For example
4700.0
800.0 5800.0