A simple c++ question..Im a beginner

This is a discussion on A simple c++ question..Im a beginner within the C++ Programming forums, part of the General Programming Boards category; I am just beginning with C++. Can you write a basic/ simple program for each, that can show the outcome ...

  1. #1
    Unregistered
    Guest

    Unhappy A simple c++ question..Im a beginner

    I am just beginning with C++.
    Can you write a basic/ simple program for each, that can show the outcome to.......
    1. Sales * = 4++

    2.Salary/=++4

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    155
    you can't increment a constant like 4 or 21 or 0.89. therefore

    sales *= 4++;

    doesn't compute. However

    sales *= 4;

    expands to

    sales = sales * 4;

    You could do this:

    int sales = 10;
    int variable = 2;
    sales *= variable++; which expands to
    sales = sales * variable++;
    and then do this to view what is in sales and variable
    cout << sales << " *** " variable;
    would print the following to the screen
    20 *** 3


    putting ++ or -- before a variable changes the variable before it is used in the expression, whereas putting ++ or -- after the variable changes the value of the variable after it is used in the expression.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-21-2005, 12:41 AM
  2. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  3. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  5. Simple stupid question from a beginner
    By oyerth in forum C++ Programming
    Replies: 1
    Last Post: 04-07-2002, 07:32 PM

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