Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

funfun123456 Group Title

4. Which of these if statements will evaluate to true? Assume that x = 5, and y = 10. if(!(y > x) || (x % y == x)) { Debug.Log("True 1"); } if( true || false ) { Debug.Log("True 2"); } if((y % x == 0) && (x < y) && (y - x != x)) { Debug.Log("True 3"); } 1 and 2 2 and 3

  • 2 years ago
  • 2 years ago

  • This Question is Open
  1. funfun123456 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    i have 1 & 2 as the answer

    • 2 years ago
  2. funfun123456 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    sorry its also in java script

    • 2 years ago
  3. ktobah Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    Just 2 is correct

    • 2 years ago
  4. funfun123456 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    thank you so much

    • 2 years ago
  5. funfun123456 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    one more for you

    • 2 years ago
  6. funfun123456 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    9. When would you use an Array while programming? To conserve variable names by combining them into one variable To go with a for loop, since they work well together To represent a chess board and the locations of all of the pieces All of the above None of the above

    • 2 years ago
  7. ktobah Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    You're welcome, it's like that : I will explain just one example, we will take the 3rd : if((y % x == 0) && (x < y) && (y - x != x)) { Debug.Log("True 3"); } (y % x == 0) --> This mean Y=10 modulo x=5 equal 0, true. (x < y) --> This mean 5 < 10, true. (y - x != x) --> This mean (10-5) different than 5, false. && --> This means And So we have (True && True && False) = False. Good luck.

    • 2 years ago
  8. ktobah Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    I think the 2nd, mean to use it with a for loop.

    • 2 years ago
  9. funfun123456 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    wouldnt you also use an array for combining them into one var

    • 2 years ago
  10. ktobah Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    I am not sure if I understand this one well, but usually the array has the same type of data for all its cells, so I really dunno. But I DON'T think so.

    • 2 years ago
  11. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    I think all of the above "To conserve variable names by combining them into one variable" I think it tries to say that instead row1 row2 row3 row4 we can just have row[] array "To go with a for loop, since they work well together" well you just go by indexes in for loop "To represent a chess board and the locations of all of the pieces" You can represent chess board by 2D array, cell[row][column]

    • 2 years ago
  12. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    if(!(y > x) || (x % y == x)) { Debug.Log("True 1"); } !(10>5) will be false 5 % 10 = 5 because 5 divided by 10 u get 0 and remainder is 5, so this is true false or true is true so first is true if( true || false ) { Debug.Log("True 2"); } true or false is true so second is true as well if((y % x == 0) && (x < y) && (y - x != x)) { Debug.Log("True 3"); } 10 % 5 = 0 10 divided by 5 is 2 and remainder is 0 so this is true 5 < 10 its true 10-5 != 5, 5 equals 5 so its false true and true and false is false answer is 1st and 2nd true

    • 2 years ago
  13. ktobah Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    Ah yeah 5 % 10 = 5, true, I make a mistake I wrote 5%10 but I was solving 10 % 5 !!!!

    • 2 years ago
  14. LemuelPogi Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    its only 2 for in 1 both statements must be false for in "or statements" one becomes true then everything is true there is this ! sign which will alternate the sign so imagine it like this !x == true||1 x should be 0 or FALSE so if it is inverted it will result to a 1 or true in number 3 it is an and statement if one statement fails then the statements under that certain condition will be skipped. it was skipped for (y - x != x) which is 10 - 5 != 5 we all know that 10 - 5 == 5 so its FALSE So the ANSWER is "2" xD hope it's clear to you xD

    • 2 years ago
  15. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @lemuelpogi dont forget ! has biggest priority..

    • 2 years ago
  16. gibugeorge Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    1 & 2

    • 2 years ago
  17. LemuelPogi Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    it has the highest priority but it will look to it later on after the operations and or etc.

    • 2 years ago
  18. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    no it wont because you said urself it has highest priority, if you don't believe type it in any programming language and see it urself

    • 2 years ago
  19. LemuelPogi Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    i mean operations will be calculated then the comparisons like = <> etc. then the and or

    • 2 years ago
  20. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    but ! has higher priority than = < > and higher priority than 'and' 'or'

    • 2 years ago
  21. LemuelPogi Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    it has a higher priority but it is used as getting only the inverse after calculating the answer on either sides xD

    • 2 years ago
  22. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    no its used as soon as you can since it has highest priority, so you evaluate whats in brackets and then immediately inverse it (10>5) is true !(10>5) is false

    • 2 years ago
  23. LemuelPogi Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    that's quite true xD

    • 2 years ago
  24. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    so ur answer is incorrect then

    • 2 years ago
  25. LemuelPogi Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    huh? in which part??? ITS TRUE

    • 2 years ago
  26. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    so u saying that 5%10==5 is true?

    • 2 years ago
  27. LemuelPogi Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    yes definitely you can not divide 5 by 10 so its a remainder xD

    • 2 years ago
  28. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    wait

    • 2 years ago
  29. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    u said that true is only 2, but first one is true too so thats why u were incorrect

    • 2 years ago
  30. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    false or true is true

    • 2 years ago
  31. LalitNagar Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    1 and 2 will evaluate to true. because y>x will be true but due to ! it will be false. x%y evaluates to 5 and 5==5 will be true. Since both the expressions are connected by OR.So the result will be true. The second case is same as first.

    • 2 years ago
  32. cs_elis Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    only 2

    • 2 years ago
  33. Tomas.A Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @cs_elis prove it

    • 2 years ago
  34. cs_elis Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    u r write @Tomas.A i made 10 mod 5 and its the opposite

    • 2 years ago
  35. cs_elis Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    1 - 2 true

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.