making less than and greater than work

This is a discussion on making less than and greater than work within the C++ Programming forums, part of the General Programming Boards category; can i do something like this if( pollutant < 3.4) { cout << " u passed " << endl; } ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    4

    Question making less than and greater than work

    can i do something like this

    if( pollutant < 3.4)
    { cout << " u passed " << endl;
    }

    else
    {
    cout << "u failed " << endl;
    }

    of course the pollutant would have already been inputed. the main question is whether or not using characters up agains numbers will work correctly. thanks for ur help in advance.

  2. #2
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    thats fine, as long as pollutant is defined and has a numeric value you can use < and >
    you can also use
    =>
    =<
    Monday - what a way to spend a seventh of your life

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4
    thanks

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    154
    You want to declare pollutant as a double or float, like:
    double pollutant;

Popular pages Recent additions subscribe to a feed

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