Question about C++
Results 1 to 6 of 6

Thread: Question about C++

  1. #1
    IT Specialist Ghost_25inf's Avatar
    Join Date
    Sep 2001
    Location
    Michigan
    Posts
    648

    Question Question about C++

    // Im having a problem getting this program to work for me. First it wont divide and second
    // how do I show desimals? like 0.62?



    # include <iostream>
    using namespace std;
    int main ()
    {
    const float k_p_m = 0.62; // problem starts here
    float 0.00;
    float miles, kms;
    cout << "Enter distance in Kilometers:" << endl;
    cin >> kms;
    miles = kms / k_p_m; //here is my second problem
    cout << "The distance in miles is "<< endl;
    cout << kms << endl;
    return 0;
    }

    // any hints you could pass my way? thanks
    S25vd2xlZGdlIGlzIHBvd2VyIQ

  2. #2
    () \/V |\| 3 |) |3\/ |\|3G47|\/3
    Join Date
    Sep 2002
    Posts
    744
    # include <iostream>
    using namespace std;
    int main ()
    {
    const float conversion = 0.62;
    float miles;
    float kms;
    cout << "Enter distance in kilometers: ";
    cin >> kms;
    miles = kms * conversion;
    cout << "The distance in miles is " << miles << endl;
    }



    If I understand correctly, your math was a little backward and you had some unneeded code. This compiles correctly in MS Visual C++

    Go Finland!
    Deviant Gallery

  3. #3
    IT Specialist Ghost_25inf's Avatar
    Join Date
    Sep 2001
    Location
    Michigan
    Posts
    648

    thank you

    Cout << " thank you so much";

    I was wondering do you know of any good books that could help me in my programming class. I mean something like book for dumbasses? Im great when it comes to networking but when it comes to programming I get lost quickly. I going to need alot of help if I want to hold my 4.0gpa status in CNT. but anyways thank you I really mean it.
    S25vd2xlZGdlIGlzIHBvd2VyIQ

  4. #4
    () \/V |\| 3 |) |3\/ |\|3G47|\/3
    Join Date
    Sep 2002
    Posts
    744
    I really love my Starting Out With C++, third ed. book by Tony Gaddis. I have several others but none are as good as this. My best advice is to (get this book and) read, read, read, and then when you "think" you know it read it again....especially the basics like functions, pointers, cstrings, etc. Then write every program you have time to write. After you've written it you may want to rewrite, refine it, etc. Practice.

    I'm serious about the book -- it's the best one I've seen.

    Best of luck!

    Go Finland!
    Deviant Gallery

  5. #5
    Leftie Linux Lover the_JinX's Avatar
    Join Date
    Nov 2001
    Location
    Beverwijk Netherlands
    Posts
    2,534
    I already had A Book on C wich is a great book and then my girlfriend got me C++ for dummies, wich wasn't at all bad
    but still no cigar.. I'll check out that book mathgirl32
    ASCII stupid question, get a stupid ANSI.
    When in Russia, pet a PETSCII.

    Get your ass over to SLAYRadio the best station for C64 Remixes !

  6. #6
    Senior Member
    Join Date
    Jul 2001
    Posts
    420
    My advice when it comes to programing books go to a bookstore with a large Computer book section grab several of the books and set with them. Find one that is targeting someone at your level and pick the best.

    I thought Teach Yourself C in 21 day was excellent -but the Same title for Java was terrible -don't know about that lines C++ book.

    I also find O'Rielly (http://ora.com)Publishers tend to produce excellent Computer related books.

    Cheers,
    -D
    If you spend more on coffee than on IT security, you will be hacked. What\'s more, you deserve to be hacked.
    -- former White House cybersecurity adviser Richard Clarke

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •