Thread: Exaplanation of Code Please

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    13

    Question Exaplanation of Code Please

    Can anyone tell me what the % sign does in the following function?

    i=z%CONST;

    Thanks.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Well, that's not a function, but that aside...

    The % sign is the modulus operator. That is to say, it gives you the remainder of dividing the left side by the right side.
    Code:
    int x = 7 % 3;
    x is now 1, because 7 / 3 is 2 with a remainder of 1.

    I'd suggest buying a C book.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    In this case it would be the modulus operator. It divides the value in z by the value in CONST, and assigns the remainder from that operation to the variable i.

    ~/

    edit: urgh...beaten again!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM