Illogical Logic what am I doing wrong? [message #1700026] |
Mon, 29 June 2015 18:15 |
John Gray Messages: 13 Registered: June 2015 |
Junior Member |
|
|
Its a simple problem to describe: when I set diff_1== 0; sometimes it executes the code for diff_1 ==1 huh-? Right? If I isolate the code in another "scratch pad" app to test, it does fine.
diff_1 = 0;
if (diff_1 == 0.00) {cout<<"flag_1";}
if (diff_1==1.00) {pennies = pennies + 1;
cout<<"increment by a penny to "<<pennies<<endl;}
-------------------------------------------------------------
works fine here -- "scratchpad"
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
double difference = 0; // or 1
if (difference == 0) {cout<<"no adjustment necessary"<<endl;}
else if ((difference)!=0) {cout<<"adjustment necessary"<<endl;}
}
if I set difference to 1 or 0 it goes where it supposed to.
[Updated on: Mon, 29 June 2015 18:27] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02695 seconds