converting inches to yards, feet, inches

The assignment is to input a number of inches and have the program output the number of yards, number of feet and the number of inches as remainders not individually. For example 49 inches, output would be 3 yards, 1 foot and 1 inch. This is what i have so far and now im stuck. What did i do wrong/what am i missing

#include <iostream>
using namespace std;

int main()
{
int inches;
int feet;
int yards;

cout << "Number of Inches\n";
cin >> inches;
cout << "Number of Yards is\n";
double yards = inches % 36;
cout << yards;

cout << "number of feet\n";
feet = inches % 12;
cout << feet;

cout << "number of inches\n";
cout << inches;

yards = inches / 36;
cout << yards;

return 0;
For some reason you are using the % operator when you are supposed to use the / character..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//My Example...You should be able to complete your exercise by studying my code

#include <iostream>
using namespace std;

int main()
{
   int user_input_Inches;
   int inches_to_feet;

     cout << "Enter number of inches" << endl;
     cin >> user_input_Inches;

    inches_to_feet = user_input_Inches / 12;
    cout << inches_to_feet << " ft" << endl;
 
   return 0;
}
Last edited on
do you know why my output window instantly closes after i input my values? usually its supposed to say press any key to continue
Use command line to open your program -- or run your program from uh.. console pauser or something, most of good IDE have one, or just run your program from IDE if your IDE has a console pauser
system("PAUSE");

^^ place that above return 0;
Last edited on
system("PAUSE");

^^ place that above return 0;


Do not do this.


Read this:
http://www.cplusplus.com/forum/beginner/1988/
Topic archived. No new replies allowed.