C++ program that takes height in centimeters and then converts heights to feet and inches.
Q19. Write a short program that asks for your height in centimeters and then converts your heights to feet and inches. (1 foot = 12 inches, 1 inch = 2.54 cm).
Ans.
#include<iostream.h>
#include<conio.h> //for clrscr();
void main()
{
float cm, foot, inch;
clrscr();
cout<<“\n Enter your height in cm: “;
cin>>cm;
inch=cm/2.54;
foot=inch/12;
cout<<“\n Your height in feet: “<<foot<<” ft”;
cout<<“\n Your height in inches: “<<inch<<” inches”;
}
Output:
Enter your height in cm: 200
Your height in feet: 6.56168 ft
Your height in inches: 78.740158 inches