How To Fix "Condition Is Always True" ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rifki
    New Member
    • Sep 2015
    • 2

    How To Fix "Condition Is Always True" ?

    #include<iostre am.h>
    void main()
    {
    double rifki;

    cout<<"Keterang an";
    cout<<endl;
    cout<<"Nilai 1 - 1,75 = D";
    cout<<endl;
    cout<<"Nilai 1,76 - 2,5 = C";
    cout<<endl;
    cout<<"Nilai 2,51 - 3,25 = B";
    cout<<endl;
    cout<<"Nilai 3,26 - 4 = A";
    cout<<endl;
    cout<<"Grade Anda Adalah = ";
    cin>>rifki;

    if(rifki<4)

    cout<<"A";

    if(rifki<3,25)

    cout<<"B";

    if(rifki<2,5)

    cout<<"C";

    if(rifki<1,75)

    cout<<"D";

    }
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    Make your floating point constants look like 3.25 instead of 3,25.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      There is also an int in there of 4. That should be 4.0. Not a good idea to mix integer and floating point.

      Comment

      Working...