I have a 2 easy question about some homework?

This is a discussion on I have a 2 easy question about some homework? within the C Programming forums, part of the General Programming Boards category; Hello, i am having a debate with a fello college about this one. Can someone set the record dtraight once ...

  1. #1
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    I have a 2 easy question about some homework?

    Hello,
    i am having a debate with a fello college about this one. Can someone set the record dtraight once and for all with this easy queastion?

    enum color {red, yellow, green, blue}

    QUESTION1:
    What is the value of the expression(enum color) ((int)red +2)?
    a. 0
    b. 1
    c. 2
    d. green
    My answer is C

    enum cday {sun, mon,tue,wen,thu,fri,sat}

    QUESTION2:
    What is the value of the expression(enum day) ((int)thu + 5)% 7)?

    a. 2
    b. sun
    c. mon
    d. tue
    MY answer is mon.

    Later Gator 12%43!&
    -c-c-out
    Last edited by correlcj; 07-18-2002 at 08:24 PM.
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231

    Re: I have a 2 easy question about some homework?

    >QUESTION1
    red is 0, therefore the calculation is 0+2 = 2.

    >QUESTION2
    thur is 4 (or it would be if you spelt it correctly ), therefore the calc is ((4 + 5 +2)% 7) = 4
    Also, because you added 7 (5+2) then mod'ed by 7, you'll always end up with what you started.

    That's what I think, at this early hour of the morning

    How did you get to mon for q2?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    How did you get to mon for q2?

    Thats simple hammer,
    I msispleed the expression.
    I meant to say: ((int)(thu + 5)%7)
    Now whatcha think all the ways from UK.
    "Be formless, shapeless, like water... You put water into a cup, it becomes the cup, you put water into a bottle, it becomes the bottle, you put it in a teapot, it becomes the teapot... Now water can flow, or it can crash, be water my friend."
    -Bruce Lee

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >((int)(thu + 5)%7)
    thu is still 4, so we have
    >(4 + 5)%7
    which is
    >9%7
    equals 2.
    Therefore the answer is Tuesday.

    That's what I think, all the way from the UK
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another Embarassingly Easy Question
    By almo89 in forum C Programming
    Replies: 2
    Last Post: 02-11-2006, 04:59 PM
  2. This is hopefully an extremely easy question...
    By rachaelvictoria in forum C Programming
    Replies: 2
    Last Post: 11-07-2005, 01:36 AM
  3. Another Homework Question
    By Trekkie in forum C++ Programming
    Replies: 3
    Last Post: 10-20-2005, 07:57 AM
  4. 4 easy question
    By Zeratulsdomain in forum C++ Programming
    Replies: 2
    Last Post: 10-15-2005, 11:43 PM
  5. Easy question about ports
    By Jaguar in forum Tech Board
    Replies: 4
    Last Post: 09-20-2003, 12:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21