Sunday, July 12, 2009

C++ If Statement syntax using 'or' operator?

if ((n1 + n2) %26gt; n3 )||(n2 + n3) %26gt; n1 )||((n1 + n3) %26gt; n2)


return true;


else


return false;





What is the proper syntax for the statement above?

C++ If Statement syntax using 'or' operator?
if (((n1 + n2) %26gt; n3 ) || ((n2 + n3) %26gt; n1 ) || ((n1 + n3) %26gt; n2))


return true;


else


return false;





//////////////////////////////////////...


// the statement just do not have the proper bracket
Reply:return true;





*Edit: If you think about it, you will see that the statement will always be true. Try plugging in some example values for n1, n2, and n3.

buy flowers

No comments:

Post a Comment