What can I do to compare two variables of type float accurately in C++, one being initialized at the time of declaration and the other being computed through the program?
When I am comparing two variables having value either 0.5 or 0.25, the program is showing the desired output but when I am comparing two variables having value either 0.333333 or 0.666667, the program is not showing the desired output. Will you please tell me where I am going wrong? Please help me in writing the correct piece of code. I am a novice and it will be a great experience to learn from you. Thank you for your concern. Here is the code with some of the outputs: