Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsDiscussion Forum → A question for fellow coders.
A question for fellow coders.
2005-08-28, 6:14 PM #1
Hey, what exactly happens when the following is executed:

main() {
printInt(5 != 5);
printInt(5 == 5);
printInt(5 < 5);
printInt(5 <= 5);
printInt(5 > 5);
printInt(5 >= 5);
printInt(5 != 2);
printInt(5 == 2);
printInt(5 < 2);
printInt(5 <= 2);
printInt(5 > 2);
printInt(5 >= 2);
}

Does it just print out 5 != 5, etc.?
2005-08-28, 6:23 PM #2
Depends on the compiler.

I don't know for sure but newer versions of C and variants will execute the statements inside the perentheses and return the result, which will be a boolean in this case.

Either that or will error expecting an integer.

EDIT: Looking at your post a second time, appears your getting help with a homework assignment, if thats the case then:

false true false true false true true true false false false true true

would be the output.
2005-08-28, 6:25 PM #3
It's suppose to be the C-- language.
2005-08-28, 8:34 PM #4
Not true/false

0
1
0
1
0
1
1
0
0
0
1
1

It'd only print "5 != 5" if the program was made to treat it as outputting a string. printINT, I'm guessing, will simply output the number corresponding to the truth of the statement (I'm assuming).
the idiot is the person who follows the idiot and your not following me your insulting me your following the path of a idiot so that makes you the idiot - LC Tusken
2005-08-29, 6:27 PM #5
PrintInt(eger)
2005-08-29, 6:56 PM #6
Why can't you just run it and find out :confused:
一个大西瓜
2005-08-29, 7:03 PM #7
Originally posted by Darkjedibob:
I thought TRUE = 0 and FALSE = -1?


Jesus christ bananas I hope you're kidding.
D E A T H
2005-08-29, 7:24 PM #8
Originally posted by Darkjedibob:
I thought TRUE = 0 and FALSE = -1?


No. Perhaps you're thinking of COG, where -1 is used to determine if no resource is attached to the symbol?
the idiot is the person who follows the idiot and your not following me your insulting me your following the path of a idiot so that makes you the idiot - LC Tusken
2005-08-29, 8:11 PM #9
I thought TRUE = 0 and FALSE = -1?
$do || ! $do ; try
try: command not found
Ye Olde Galactic Empire Mission Editor (X-wing, TIE, XvT/BoP, XWA)
2005-08-29, 10:20 PM #10
Originally posted by Pommy:
Why can't you just run it and find out :confused:


No kidding... it would've ****ing been faster than posting it here
"it is time to get a credit card to complete my financial independance" — Tibby, Aug. 2009
2005-08-30, 4:52 PM #11
Wolfy is correct, it would print
0
1
0
1
0
1
1
0
0
0
1
1

or
010101100011
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-08-30, 4:58 PM #12
Originally posted by Pommy:
Why can't you just run it and find out :confused:


He doesn't have the program to run it, possibly.
Sneaky sneaks. I'm actually a werewolf. Woof.
2005-08-30, 6:38 PM #13
lol, that's no excuselol!

here you go chap: [url]www.theprogramthatrunsit.com[/url]

enjoiz.
2005-08-30, 6:50 PM #14
I thought that site was real at the frst glance..... :(
SnailIracing:n(500tpostshpereline)pants
-----------------------------@%
2005-08-30, 7:47 PM #15
Originally posted by Echoman:
I thought that site was real at the frst glance..... :(

Yeah, I thought it would be some sort of online compiler or interpreter that would return your data from code heh...poo
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________

↑ Up to the top!