Thursday, July 9, 2009

Basic C++ Programming help?

1. 2 * 6 - 5 + 8 % 5


2. 3 * 5 - 19 + 7 % 4


3. 5 * 5 - 19 - 6 % 7


4. 3 * 5 - 12





also, what output will this give me?


int a = 5, b = 4, c = 1 ; if ( a %26lt; b + 1 ) {


printf("Tea, Earl Grey, Hot!\n") ; }


else if ( a %26gt; b + c )


{ printf("Ahead warp factor 9. Engage!\n") ; }


else if ( a % b %26gt;= c )


{ printf("Warp core breach in 20 seconds!\n") ; }


else { printf("I sense a lot of anxiety in this room.\n") ; }





Wrap core break in 20 seconds??





Please help and be so kind to explain if u can. Thanks.

Basic C++ Programming help?
Well, for the first four questions you just have to do the math, and perform the operations in order. The modulus operation (%) returns the remainder in a division problem- for example, 3%2=1 because if you divide 3 by 2 you are left with a remainder of 1.





For the next section, you are correct in that it would print "Warp core break in 20 seconds" since 5%4=1, which makes the statement (5%4%26lt;=1) true in the last else if statement.





Hope that helped!

love song

No comments:

Post a Comment