-
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
-
# 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++
-
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.
-
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!
-
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
-
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