Thread: Post and pre incremement question

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    5

    Post and pre incremement question

    Hello,

    I was just wondering how to do a post/pre increment question. I know how to do post and pre incremement but this question has another thing in it. Here is the code:

    Code:
    int c;
    int a = 13, b = 5;
    
    c = a++%3 + --b;
    The question then asks what would be the value of c?
    Can anyone help much would be appreciated.
    P.S. I dont understand what the %3 does

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Compile the code and see the value for yourself.

    Soma

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    % is the modulus operator (takes remainder after divide by 3).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 02-20-2005, 08:48 AM
  2. HTTP Post Question
    By penney in forum C# Programming
    Replies: 2
    Last Post: 06-07-2004, 09:26 AM
  3. The best post ever!!!
    By adamviper in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 12-04-2002, 10:22 AM

Tags for this Thread