Answer to Question #325630 in C++ for remo

Question #325630

Write a program that takes length as input in feet and inches and convert it into centimeters. Using the constant for declaration of conversion constants. To calculate the equivalent length in centimeters, you need to multiply the total inches by 2.54. Similarly, to find the total inches, you need to multiply the feet by 12 and add the inches. 


1
Expert's answer
2022-04-07T17:36:14-0400
#include <iostream>
using namespace std;


const int INCH_PER_FOOT=12;
const double CM_PER_INCH=2.54;


int main() {
    int inches, feet;
    cout << "Enter a length in foot and inches: ";
    cin >> feet >> inches;


    int tot_inch = inches + INCH_PER_FOOT * feet;
    double cm = tot_inch * CM_PER_INCH;


    cout << "It is equal " << cm << " cm";


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS