0% found this document useful (0 votes)
44 views1 page

Commercial Revolution

The document provides instructions for writing a C++ program that converts lengths given in feet and inches to centimeters. It explains that the program should get feet and inches as input, convert to total inches, then convert inches to centimeters and output the result. It describes declaring constants for the conversion ratios rather than using fixed values, and lists the steps to write the complete program, including comments, headers, constants, and the main function definition.

Uploaded by

Sanju Durgapal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views1 page

Commercial Revolution

The document provides instructions for writing a C++ program that converts lengths given in feet and inches to centimeters. It explains that the program should get feet and inches as input, convert to total inches, then convert inches to centimeters and output the result. It describes declaring constants for the conversion ratios rather than using fixed values, and lists the steps to write the complete program, including comments, headers, constants, and the main function definition.

Uploaded by

Sanju Durgapal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

VARIABLE, OPERATOR AND EXPRESSION

[SET – 3]
Question 1 Write a program that takes length as input in feet and inches. The program should
then convert the lengths in centimeters and display it on screen. Assume that the
given lengths in feet and inches are integers.

Based on the problem, you need to design an algorithm as follows:


1. Get the length in feet and inches.
2. Convert the length into total inches.
3. Convert total inches into centimeters.
4. Output centimeters.

To calculate the equivalent length in centimeters, you need to multiply the total
inches by 2.54. Instead of using the value 2.54 directly in the program, you will
declare this value as a named constant. Similarly, to find the total inches, you
need to multiply the feet by 12 and add the inches. Instead of using 12 directly in
the program, you will also declare this value as a named constant. Using a named
constant makes it easier to modify the program later.

To write the complete length conversion program, follow these steps:


1. Begin the program with comments for documentation.
2. Include header files, if any are used in the program.
3. Declare named constants, if any.
4. Write the definition of the function main.

1 www.cppforschool.com

You might also like