By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 946 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

How To Fix "Condition Is Always True" ?

P: 2
#include<iostream.h>
void main()
{
double rifki;

cout<<"Keterangan";
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";

}
Nov 9 '15 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 2,396
Make your floating point constants look like 3.25 instead of 3,25.
Nov 9 '15 #2

weaknessforcats
Expert Mod 5K+
P: 9,197
There is also an int in there of 4. That should be 4.0. Not a good idea to mix integer and floating point.
Nov 9 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.