Thread: Big problem how to calculate units

  1. #1
    Registered User
    Join Date
    Sep 2003

    Big problem how to calculate units

    I am having a problem with the line that calculates the data. It keeps saying non-lvalue. I noticed
    there are differences between, my book (borland) and my compiler (bloodshed), am I using an old method to calculate units? Any help you can offer would be greatly appreciated.

    // Height in miles
    // going to be a program to calculate height in diff units
       unsigned int feet;
       unsigned int inches;
       unsigned int heightIninches;
       unsigned int heightInmiles;
       unsigned int f = 5280;
        std::cout<<"What is your height? \n  ";  //outputs the question to the screen
        std::cout<<"First give the feet, then the inches, ok? \n ";
        system ("pause");
        std::cout<<"OK First, how many feet are you tall? \n ";
           std::cin>>feet;                   //allows input to the num variable
           system ("pause");
           std::cout<<"and now the trailing number of inches you are tall \n ";
    return heightIninches;
           std::cout<<"So your height in inches is "<< heightIninches << "\n";
           system ("pause");
           std::cout<<"To see you height in miles press any key  \n";
           system ("pause");
                  f/heightIninches = heightInmiles;
    return heightInmiles;
           std::cout<<"You are "<< heightInmiles << " miles tall \n";
           system ("pause");
           return 0;
    //63360 = num of inches in a mile

  2. #2
    Registered User axon's Avatar
    Join Date
    Feb 2003
    the problem is here:
    //the variable that you want to have a value assigned 
    //to should be on the left side of the assign operator
    //you don't write:
    12 = x; //you write:
    x = 12;
    //so $$$$ch them arround:
    heightIninches = (feet*12 + inches);
    you don't need the return heigtIninches that is in the next line.
    Do the same for height in miles....

    int main()
    and istead of writing std::whatever, you could just have this:
    #include <iostream>
    using namespace std;
    some say this clutters stuff up, but for your usage it is great!


    some entropy with that sink?

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001

    For future reference....

    l-value means left-value.

    A statement with an equal sign is an assignment statement. Its NOT a mathmatical equation. It makes the variable on the left equal to the value of whatever is on the right.

    These two statements are NOT the same (in programming).
    x = y ; // Make x equal to y
    y = x ; // Make y equal to x

    In BASIC, the assignment statement is also called a LET statment. (The word "LET" is optional in BASIC):

    LET x = 12 'This is BASIC... Don't try it in C++ !!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  2. I have big problem with encryption by ASCII
    By LINUX in forum C++ Programming
    Replies: 7
    Last Post: 04-29-2007, 12:46 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  4. Big Problem With Passing an Matrix to Main Function
    By Maragato in forum C Programming
    Replies: 4
    Last Post: 06-14-2004, 11:06 PM
  5. problem with selection code
    By DavidP in forum Game Programming
    Replies: 1
    Last Post: 06-14-2004, 01:05 PM