+ 1
Why am I getting answer as .445 and the expected answer is .45? (Kaleidoscope problem)
Should i round off the answer? Or am i making any mistake in the code? #include <iostream> using namespace std; int main() { float num; cin >> num; if (num >1){ float cost = num * 5.00; float disc = cost * 0.1; float new_cost = cost - disc; float tax = 0.07 * new_cost ; float aft_tax = new_cost + tax; cout << aft_tax; } if (num==1) { float tax1 = 0.07 * 5.00; float cost1 = tax1 + 5.00; cout << cost1 ; } return 0; }
5 Answers
+ 4
I solved it in python and I had to round it.
+ 2
Round it upto 2 decimal digits..
double type gives you more accurate values..
0
Hello
0
Try using double instead of float
0
Round (ans, 2) should solve that issue