|
-
Jan 9th, 2001, 09:47 PM
#1
Originally posted by Help
-not to good at C but I know your last part is wrong.
should be
Code:
if (y!=='y') break;
= means assigns
== means equal.
Maybee you knew that maybee not. 
he was correct,
Code:
//.....
if (y=5) cout << "true";
that always evaluates to true, well because you are assigning 5 to y, and assuming that goes well, it returns true, meaning y now holds the value 5.
Code:
//.....
if (y == 5) cout << "true";
if y was equal to five, the output would be true, if not, well, there would be no output.
Code:
if (y != 5) cout << "false";
if y was equal to five, that would not evaluate to true, it is asking if y is not equal to 5,
this code accomplishes the same thing:
Code:
if (!(y == 5)) cout << "false";
obviously the uppermost code is easier to read and understand. this code is saying "if (not) y equals 5" the other is saying "if y does not equal 5"
what you are doing,
Code:
if (y !== 5) cout << "true"
well, that will probably give an error, becase not equals is !=, NOT !==.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|