Write a C++ program to convert meters to feet. The program should
request the starting meter value, the number of conversions to be made, and the increment
between metric values. The display should have appropriate headings and list the meters and
the corresponding feet value.Use the relationship that 1 meter = 3.281 feet.
write the above .programs using a for loop.
1
Expert's answer
2013-03-18T11:59:27-0400
#include <iostream> #include <conio.h>
using namespace std; //main function int main() { int numberconversionsmade=0;//declare variable numberconversionsmade double startvalue=0;//declare variable startvalue double feetvalue=0;//declare variable feetvalue cout<<"Enter starting meter value: "; cin>>startvalue;//input startvalue cout<<"Enter number of conversions to be made: "; cin>>numberconversionsmade; //using a for loop. for(int i=startvalue;i<=startvalue+numberconversionsmade;i++){ feetvalue=3.281*i;//calculate feet cout<<i<<" = "<<feetvalue<<" ";//show result } getch(); return 0; }
Comments
Leave a comment