samedi 3 avril 2021

relational operator (<=) not working in c++ with conditional loop [duplicate]

Below is my code which should return NO if value is greater than or equal to 9.58 and YES if value is smaller. I tried this because strictly smaller than T < 9.58(return YES) wasn't working and returning YES even though value was 9.58. But the same is happening again and when I print value to console it returns 9.58 so value isn't wrong. Can someone please explain. I have tried using: value > 9.58 || value == 9.58 also but that worked the same.

  if(value >= 9.58) {
    cout << "NO" << endl;
    cout << value << endl;
  } else {
    cout << "YES" << endl;
    cout << value << endl;
  } 

OUTPUT:

YES
9.58

I am sorry if it's a silly mistake but I am new to C++ and couldn't find an answer. Thank you.

Aucun commentaire:

Enregistrer un commentaire