else if(response == 5) {
cout << "Remainder" << endl;
cout << "Enter first number: ";
cin >> fn;
cout << "Enter second number to divide and get remainder: ";
cin >> sn;
float ovrl = (fn % sn);
cout << ovrl << endl;
system("PAUSE");
goto startagain;
}
The code returns this error:
invalid operands of types `float' and `float' to binary `operator%'
Full code here:[spoiler]
#include <iostream>
using namespace std;
float fn = 0;
float sn = 0;
float response = 0;
int yn = 0;
int main() {
main:
system("CLS");
cout << "1. Division" << endl << "2. Multiplication" << endl << "3. Addition" << endl << "4. Subtraction" << endl << "5. Remainders" << endl;
cin >> response;
system("CLS");
if(response == 1) {
cout << "Divison" << endl;
cout << "Enter first number: ";
cin >> fn;
cout << "Enter second number to divide: ";
cin >> sn;
float ovrl = (fn / sn);
cout << ovrl << endl;
system("PAUSE");
goto startagain;
}
else if(response == 2) {
cout << "Multiplication" << endl;
cout << "Enter first number: ";
cin >> fn;
cout << "Enter second number to multiply: ";
cin >> sn;
float ovrl = (fn * sn);
cout << ovrl << endl;
system("PAUSE");
goto startagain;
}
else if(response == 3) {
cout << "Addition" << endl;
cout << "Enter first number: ";
cin >> fn;
cout << "Enter second number to add: ";
cin >> sn;
float ovrl = (fn + sn);
cout << ovrl << endl;
system("PAUSE");
goto startagain;
}
else if(response == 4) {
cout << "Subtraction" << endl;
cout << "Enter first number: ";
cin >> fn;
cout << "Enter second number to subtract: ";
cin >> sn;
float ovrl = (fn - sn);
cout << ovrl << endl;
system("PAUSE");
goto startagain;
}
else if(response == 5) {
cout << "Remainder" << endl;
cout << "Enter first number: ";
cin >> fn;
cout << "Enter second number to divide and get remainder: ";
cin >> sn;
float ovrl = (fn % sn);
cout << ovrl << endl;
system("PAUSE");
goto startagain;
}
else {
goto main;
}
startagain:
system("CLS");
cout << "Would you like to start again? (1 = Y / 2 = N)";
cin >> yn;
if(yn == 1) {
goto main;
}
else if(yn == 2) {
exit(0);
return 0;
}
else {
exit(0);
}
}
[/spoiler]