Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using c++ Write a program to convert feet to meters. The conversion from feet to meters is: 1 foot = 0.3048 meters The input will
Using c++
Write a program to convert feet to meters. The conversion from feet to meters is:
1 foot = 0.3048 meters
The input will be numbers passed on the command line. You will want to use the library function atof()
to convert a string
into a float
. For example, consider the following code:
#include // the library for atof() #include // the library for atof() using namespace std; int main() { char text[] = "3.14159"; // a c-string float pi; // the float where the answer will go pi = atof(text); // atof() translates the c-string into a float cout << pi << endl; // this better be 3.14159 return 0; }
Pay special attention to the #include
code. You will need that for this assignment!
Example
Consider the output of a program called a.out
:
a.out 1 2 3
1.0 feet is 0.3 meters
2.0 feet is 0.6 meters
3.0 feet is 0.9 meters
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started