Question

An Introduction to Programming With C++ (8th Edition) Chapter 9, Exercise 18

An Introduction to Programming With C++ (8th Edition)

Chapter 9, Exercise 18

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

/******************************************************************************

Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;
double inch2cm(double inch)
{
return 2.54*inch;
}
double cm2inch(double cm)
{
return cm/2.54;
}
void menu()
{
cout<<"Press 1 to convert from inches to cm\nPress 2 to convert from cm to inches\nEnter your choice: ";
}
int main()
{
menu();
int ch;
cin>>ch;
if(ch==1)
{
double inch;
cout<<"Enter inches: ";
cin>>inch;
cout<<inch<<" inches in cm is "<<inch2cm(inch)<<endl;
}
else
{
double cm;
cout<<"Enter cm: ";
cin>>cm;
cout<<cm<<" cm in inches is "<<cm2inch(cm)<<endl;
}
  

return 0;
}

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
An Introduction to Programming With C++ (8th Edition) Chapter 9, Exercise 18
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT