c++ programming help
so z is a float variable, it says that x = y * z is bad programming style but i don't know why.
x = y * z; is the actual statement, also all the other variables are int
Sorry brother, am not made for math...
umm this isn't math
the problem doesn't lie in the math
i believe i might have to put the float variable before the int, like this x = z * y;
Dude this is beyond me...
otay
why dont you see the error it accumulates in c++
it's doesn't have bad syntax just bad programming style
atleast i think
add y*z to itself 10000 times and see the difference between z*y 10000 times
ur such a troll
i dont know how C++ floating point arithmetic works, it might do int * float and float * int in different ways
why?
cause reasons
jk
oh well ill just post what i think
turn in*
not post
you should google it im sure you can find these kinda questions there a lot
Mixing and matching int and float in a calculation is generally not considered a good practice. For one there will be truncation error in the case when int y = 2; float z = 3.2 then int x = y * z will be 6. But if you must mix them, use an explicit cast. Here is an example of mixing and matching int and float that gives different results: int p = 3; int q = 2; float x = 7.3; float result; result = x + p/q; (result will be 8.3 because p/q = 3/2 is an integer division that will be truncated to 1 which when added to 7.3 yields 8.3) result = x + (float) p / (float) q; (result will be 8.8)
For C++, ask in comp sci section.
kk
Join our real-time social learning platform and learn together with your friends!