| | |
new to C++
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2005
Posts: 17
Reputation:
Solved Threads: 0
Hi, I'm totally new to C++ and so far am extremely confused. I was wondering if anyone could give me any help with one of my assignments. Basically I don't know where to even start. I think if maybe someone can help me get started maybe I can figure this problem out. Anyways, here's the problem...
Write a program that prompts the user to input a length expressed in centimeters. The program should then convert the length to inches and output the length expressed in yards, feet, and inches, in that order. For example suppose the input for centimeters is 312. To the nearest inch, 312 centimeters is equal to 123 inches. 123 inches would thus be output as:
3 yards, 1 foot, and 3 inches.
Any help would be greatly appreciated.
Write a program that prompts the user to input a length expressed in centimeters. The program should then convert the length to inches and output the length expressed in yards, feet, and inches, in that order. For example suppose the input for centimeters is 312. To the nearest inch, 312 centimeters is equal to 123 inches. 123 inches would thus be output as:
3 yards, 1 foot, and 3 inches.
Any help would be greatly appreciated.
Well we dont do homework but here is a basic idea of how you would go about this. first you would need to ask the user to input the length in centimeters using cin. and then you take the info you get and you would then have the program convert centimeters to inches. and from inches its not hard to figure out how many yards, feet and inches that equals
try to post atleast alittle bit of code next time thanks
try to post atleast alittle bit of code next time thanks
•
•
Join Date: Feb 2005
Posts: 17
Reputation:
Solved Threads: 0
Thanks for the help...Have I started this off right so far?
#include <iostream.h>
using namespace std;
const double conversion = 2.54
const int inchesPerFoot = 12
int main()
{
int centimeters, inches;
int yards, feet;
cout << "Enter length in centimeters: ";
cin >> centimeters;
cout << endl;
cout << "The number entered was " << centimeters
<< " for centimeters. " << endl;
return 0;
}
#include <iostream.h>
using namespace std;
const double conversion = 2.54
const int inchesPerFoot = 12
int main()
{
int centimeters, inches;
int yards, feet;
cout << "Enter length in centimeters: ";
cin >> centimeters;
cout << endl;
cout << "The number entered was " << centimeters
<< " for centimeters. " << endl;
return 0;
}
You need to terminate the following statements with semicolons: And this was okay many years ago... ...but if you are living in the 21st century, it should be... ...especially since you are...
const double conversion = 2.54; const int inchesPerFoot = 12;
C++ Syntax (Toggle Plain Text)
#include <iostream.h>
C++ Syntax (Toggle Plain Text)
#include <iostream>
C++ Syntax (Toggle Plain Text)
using namespace std;
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Other Threads in the C++ Forum
- Previous Thread: help finding and solving a problem
- Next Thread: How do assign a file name to save in C
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count data delete deploy desktop developer directshow dll download dynamic encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node number output parameter pointer problem program programming project proxy python read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






