Thread: Taking away in increments

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    97

    Taking away in increments

    i know the way to subtract 1 from a variable. its like x-- right? with x ur variable name? how about taking away more than one? i would use a while statement right? thx

  2. #2
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164

    Re: Taking away in increments

    Originally posted by oobootsy1
    i know the way to subtract 1 from a variable. its like x-- right? with x ur variable name? how about taking away more than one? i would use a while statement right? thx
    use
    x -= 4;
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  3. #3
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    or x=x-4, but I always use x-=4
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  4. #4
    Registered User
    Join Date
    Feb 2004
    Posts
    127
    by default when you want to subtract from a variable

    x=x-4;

    but in C we found that you can make
    x-=4;

    which is ofcourse easier

    for more simplification there is a way ONLY for incrementing to decrementing

    x++; //incrementing
    x--; for decrementing

    But as Walt and major said concerning subtractin more than one its prefered to make
    x-=4;

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    97
    ill just make it a new value. like x=3. thx anyways

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. XP taking about 8 min to boot and 12 to respond
    By VirtualAce in forum Tech Board
    Replies: 28
    Last Post: 09-21-2008, 02:15 AM
  2. taking Function's address
    By arjunajay in forum C++ Programming
    Replies: 2
    Last Post: 09-12-2005, 05:55 AM
  3. Stock Taking program
    By C Babe in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2003, 07:40 PM
  4. q-Analysis - worth taking a course over?
    By Captain Penguin in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-04-2002, 05:09 PM
  5. Please help me
    By teedee46 in forum C++ Programming
    Replies: 9
    Last Post: 05-06-2002, 11:28 PM