C++ Output Conversion Error -


i'm supposed make code converts feet , inches meters , centimeters. when run code, don't should get. example, input 1 foot , 0 centimeters. should 0.3048 meters , 0 centimeters instead i'm getting 1 meters , 0 centimeters . help!

#include <iostream> using namespace std;  void getlength(double& input1, double& input2); void convert(double& variable1, double& variable2); void showlengths(double output1, double output2);  int main() {     double feet, inches;     char ans;          {         getlength(feet, inches);         convert(feet, inches);         showlengths(feet, inches);          cout << "would go again? (y/n)" << endl;         cin >> ans;         cout << endl;      } while (ans == 'y' || ans == 'y'); }  void getlength(double& input1, double& input2) {     cout << "what lengths in feet , inches? " << endl;     cin >> input1 >> input2;     cout << input1 << " feet , " << input2 << " inches converted "; }  void convert (double& variable1, double& variable2) {     double meters = 0.3048, centimeters = 2.54;      meters *= variable1;     centimeters *= variable2; }  void showlengths (double output1, double output2) {     cout << output1 << " meter(s) , " << output2 << " centimeter(s)" << endl; } 

any appreciated. thanks!

meters *= variable1; centimeters *= variable2; 

should be

variable1 *= meters; variable2 *= centimeters; 

what last comment said: you're not assigning product variables you've passed reference (variable1 , variable2), values not changing original input of 1 , 0.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -