There is also reference, tutorials and articles at the top left of this page. You might find it easier to read, but sometimes things are harder to find. cppreference is authoritative but quite technical.
I'm sorry to ask this but is there any other way of writing it. I read what each thing means but I don't quite understand it. I appreciate all the help I get.
#include <iostream>
usingnamespace std;
int main()
{
int inches = 0;
int feet = 0;
int yards = 0;
int miles = 0;
int number = 0;
cout << "Enter inches: ";
cin >> number;
/*
12 inches per foot
36 inches per yard
63360 inches per mile
*/
// USE MODULAR ARITHMETIC - CHECK THE TUTORIALS
// GET THE MILES
miles = number / 63360; // Whole miles
number = number % 63360; // number is now the leftover inches
// GET THE YARDS
yards = number / 36; // Whole yards
number = number % 36; // number is now revised leftover inches
// YOU CAN DO THE REST
cout << miles << " mile " << yards << " yards " << number << " inches (leftover)" << endl;
return 0;
}
A few tips:
1. You are best off by working out a simple example on paper before you write code. You get a clear picture of what needs to be done. That's what pseudocode is all about. Remember, all the machine ever does is what you can do manually - just more reliably (probably) and quicker (probably).
2. Make sure you understand the difference between types - double, int etc because dividing integer values can give you unexpected results. eg in integers, 1/2 is 0 not 0.5
3. The tutorials on this site are useful.
eg http://www.cplusplus.com/doc/tutorial/operators/