d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Help With C++
Add Reply New Topic New Poll
Member
Posts: 38,019
Joined: Feb 14 2011
Gold: 6.90
Sep 9 2015 03:17pm

I don't know how to get the if commands to work
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 9 2015 05:18pm
2 things.

1) use == instead of =
if (result == 0)

since you use a single =, it is assigning result to be 0. since 0 is false, the if statement doesn't execute. since 0 is not greater or less than 0, the other ifs aren't executed either.

2) minor point, but you should indent the body of the if condition, and also use braces around the body. it's not needed, but it helps you pick up bugs much faster.

instead of:

Code
if (result == 0)
cout << "result is zero" << end1;


do:
Code
if (result == 0){
cout << "result is zero" << end1;
}


This post was edited by carteblanche on Sep 9 2015 05:18pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 9 2015 05:20pm
and i just noticed your second topic:
http://forums.d2jsp.org/topic.php?t=73189617&f=122&v=1

Don't do that or we'll waste time when it's already solved.

/edit: ah great, you made 4 topics, not just 2. you need to update your shit when you get your answer.

This post was edited by carteblanche on Sep 9 2015 05:45pm
Member
Posts: 1,799
Joined: Jan 15 2008
Gold: 1.00
Sep 10 2015 03:53pm
Quote (carteblanche @ Sep 9 2015 05:20pm)
and i just noticed your second topic:
http://forums.d2jsp.org/topic.php?t=73189617&f=122&v=1

Don't do that or we'll waste time when it's already solved.

/edit: ah great, you made 4 topics, not just 2. you need to update your shit when you get your answer.


this.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll