How can I check if two real numbers are equal to the ones in the condition stated below?

Nelson Canhoto

New member
include <stdio.h>

int main()

{

float A, B;

printf("Insert 2 real numbers.");
scanf("%f %f", &A, &B);

if(A==0.5 && B==2.1)/*-->It will be true if A is true, but it won't check for B if B is a real number
maybe due to some inaccuracy on the float data type (0.1=0.100000)?)*/

printf("(Y)");

else

printf("%.1f",B);
scanf("%f", &A);//-->here because DEV CPP ends the .exe if no further input is required (how can

return 0;//I write something in C like "press any key to exit")?

}

Thanks in advance.
 
Back
Top