Thread: increment operator Question from a beginner

  1. #1
    Unregistered
    Guest

    Unhappy increment operator Question from a beginner

    if X=4

    what doe this statement do..........sales*=X++;
    and can you write a basic program to show outcome?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    >>sales*=X++;

    It means sales = sales * X, and then increase X by 1.

    Therefore

    int sales = 10;
    int X = 10;

    sales*=X++;

    cout << "Sales is now 10 times 10 = " << sales <<endl;
    cout << "X is now incremented and is now " << X;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Same old beginner question...
    By Sharmz in forum C Programming
    Replies: 15
    Last Post: 08-04-2008, 11:48 AM
  2. What are some good beginner programs I shouold make?
    By oobootsy1 in forum C# Programming
    Replies: 6
    Last Post: 08-09-2005, 02:02 PM
  3. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM
  4. Post increment and pre increment help
    By noob2c in forum C++ Programming
    Replies: 5
    Last Post: 08-05-2003, 03:03 AM
  5. low value, high value and increment
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 11-25-2001, 09:01 AM