Non-Lvalue in assignment error

I'm getting this error in the ending function of my program. The purpose of the program is to convert feet and inches to meters and centimeters. Its giving me an error where I have a variable to store the remainder so I can add it as centimeters. I will bold where the error is located.

#include <iostream>
using namespace std;

void input(int& feet, int& inch);
void calc(int feet, int inch, int& meter, double& cm);
void output(int meter, double cm);

int main()
{
char selection;
int feet, inch, meter, meterExtra, remainder;
double cm, cmExtra;


cout << "Hello. This program will convert feet to inches to the most\n"; //Explaining Program
cout << "Aprox. whole centimter.\n";

//Calling Functions
input(feet, inch);
calc(feet, inch, meter, cm);
output(meter, cm);
//Repeating The Program
cout << endl;
cout << "If you want to try again press Y\n";
cout << "If you wish to end the program press N\n";
cout << endl;

cin >> selection;

if(selection == 'Y')//If "Y" is used, program will repeat itself
{
system ("cls");
main();
}
else //If anything else is pressed, program will end
{
cout << "Goodbye\n";
}

return 0;
}
void input(int& feet, int& inch)
{
cout << "Please enter your distances in feet and inches.\n"; //Prompting User
cout << "Only positive numbers work.\n";
cin >> feet;
cin >> inch;
//Echoing Input
cout << "Your distance is " << feet << " feet and " << inch << " inches.\n";
}
void calc(int feet, int inch, int& meter, double& cm)
{
double meter2, meterExtra, cmExtra, remainder;

meter2 = feet * 0.3048;
meter = static_cast<int>(meter2);
meter2 - meter = remainder; //This is where the error is located
remainder = (remainder * 100) + cm;
cm = inch * 2.54;
if (cm > 100)
{
meterExtra = cm / 100;
cmExtra = cm - (meterExtra * 100);
}
}


void output(int meter, double cm)
{
//Outputting Results
cout << "Your converted distances are " << meter << " meters and\n";
cout << cm << " centimeters.\n";
}
You can assign something to a variable, but not to "meter2 - meter".
You probably meant meter2 = remainder + meter;
I fixed that, now it runs, but it still doesnt do what it should which is to save that fraction and add it to the centimeters
Nevermind I have fixed it. Thank you very much Athar!
Topic archived. No new replies allowed.