John T.

asked • 05/26/18

Why the loop doesn't stop ?

#include <stdio.h>
int main(void){
double a = 3.0, b = 3.4;
while(a != b){
puts("Not Equal.");
a = a + 0.1;
}
puts("Now Equal");
getchar();
return 0;
}

// If b = 3.1 or 3.2 it works perfectly.

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.