Thread: General question

  1. #1
    Registered User
    Join Date
    Oct 2008
    Location
    Uinted States
    Posts
    8

    Question General question

    I have a teacher, he does not know what he's doing.

    so I have a question for you.

    when you use switch statements.

    sometimes you need to write like this code before you start write the cases.

    I haven't used it, I try to avoid it in my programs.

    Code:
    switch ( x /= 200)
    or
    switch ( x % 200)
    can I ask you guys, is there any website or a thread on this forum tell me how I can use ( % ) or ( /=) , etc.

    thanks

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    x /= 200 will change x to x / 200, and then switch on that value.

    x % 200 calculates the remainder of x divided by 200.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Location
    Uinted States
    Posts
    8
    Thanks
    Is there any condition I have to know?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by saudi-vip View Post
    Thanks
    Is there any condition I have to know?
    Condition for what?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Oct 2008
    Location
    Uinted States
    Posts
    8
    I mean ( /= and % )
    i know these two is there any

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Oct 2008
    Location
    Uinted States
    Posts
    8
    yes.
    I have problem with names too.
    this is the first semester for me studying C.
    so, I don't know what you called them.

  8. #8
    Registered User
    Join Date
    Oct 2008
    Location
    Uinted States
    Posts
    8
    thanks Mats

  9. #9
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Maybe you should also find a better teacher if he can't even answer a simple question like that.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  10. #10
    Registered User
    Join Date
    Oct 2008
    Location
    Uinted States
    Posts
    8
    I don't trust him,
    so I would like to ask you guys before doing something stupid ,

  11. #11
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    switch ( x /= 200) != switch(x / 200)

    I think the left-most one will get your code doing crazy crap that you didn't want. Though I can't pretend like I know that for sure.

  12. #12
    Registered User
    Join Date
    Oct 2008
    Location
    Uinted States
    Posts
    8
    that's right.
    C programming drives me crazy with its crazy crap.

    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A general question aout programming?
    By bradt93 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 03-26-2008, 11:00 AM
  2. winsock - general question
    By keira in forum Windows Programming
    Replies: 1
    Last Post: 09-28-2007, 01:56 PM
  3. another exercise question
    By luigi40 in forum C# Programming
    Replies: 3
    Last Post: 11-28-2005, 03:52 PM
  4. general programming compatability question
    By Metarectilinear in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 10-25-2002, 11:51 PM
  5. general question regarding a function parameter
    By mlupo in forum C Programming
    Replies: 7
    Last Post: 10-13-2002, 07:32 PM

Tags for this Thread