Thursday 11 February 2016

Dealing with Data (C++ Primer Plus Sixth Edition Solution Manual) Question-1

Leave a Comment
Questions:

Write a short program that asks for your height in integer inches and then converts your height to feet and inches. Have the program use the underscore character to indicate where to type the response. Also use a const symbolic constant to represent the conversion
factor.

Explanation:

Below mention code is compiled in Visual Studio 2015 and Code Blocks 13.12,output snap is attached.. If any problem you feel and you want some explanation feel free to contact us.

Code:

/**************************************************|
/*************C++ Programs And Projects************|
***************************************************/


#include <iostream>
using namespace std;

void main() {
       cout << "Enter your height (in inches): ________\b\b\b\b\b\b\b\b";
       int height;
       cin >> height;

       const int inchesPerFoot = 12;
       int feet = height / inchesPerFoot;
       int inches = height % inchesPerFoot;

       cout << height<< " inches are "<< feet<< " feet, "<< inches<< " inch(es)."<< endl;
}




Output:
Write a short program that asks for your height in integer inches and then converts your height to feet and inches. Have the program use the underscore character to indicate where to type the response. Also use a const symbolic constant to represent the conversion  factor


Related Articles:

C++ Primer Plus Sixth Edition Complete Solution Manual 

C++ Books Solution

 

 

If You Enjoyed This, Take 5 Seconds To Share It

0 Questions: