Like Tree1Likes
  • 1 Post By phantomotap

Post and pre incremement question

This is a discussion on Post and pre incremement question within the C Programming forums, part of the General Programming Boards category; Hello, I was just wondering how to do a post/pre increment question. I know how to do post and pre ...

  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
    4,260
    Compile the code and see the value for yourself.

    Soma
    laserlight likes this.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    % 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, 07: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, 09:22 AM

Tags for this Thread


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