I keep getting "uninitialized variable 'y' used" and "uninitialized variable 'x' used." I've tried many things, and I can't seem to fix it. any input would be greatly appreciated. Please keep in mind, I am not yet completely finished with the code. I am looking to fix this before I move on to void Mulfloats (void); Thanks, here is my code.
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
void help(void);
void SubIntegers(void);
int getInteger(void);
void displayIntegers(int n1, int n2);
void Mulfloats(void);
int getFloat(void);
void displayIntegers(float& n1, float& n2, float& s);
int main(void)
{
char choice;
while (1)
{
cout << "\tSelection Menu\n";
cout << "*******************************\n";
cout << " H Help\n";
cout << " S Subinteger\n";
cout << " M MullFloats\n";
cout << " Q Quit\n";
cout << " Input your choice and press Enter: ";
cin >> choice;
switch (choice)
{
case 'h':
case 'H':
help();
break;
case 's':
case 'S':
SubIntegers();
break;
case 'm':
case 'M':
float x, y;
{
cout << "Enter two valid float numbers\n";
cin >> x >> y;
cout << "x=" << x << endl;
cout << "y=" << y << endl;
cout << setw(8) << setprecision(6) << "The Product of the two float numbers is " << (x*y) << endl;
}
break;
case 'q':
case 'Q':
cout << "The program terminated per the user request...\n";
exit(0);
default:
cout << "\tNot a Valid Choice. \n";
cout << "\tValid choices are 1, 2, 3, 4\n";
cin >> choice;
}
}
return EXIT_SUCCESS; // the program returns to the first line
}
void help(void)
{
cout << "Press h or H to access Help Menu," << endl
<< "Press s or S to access Subinteger Menu," << endl
<< "Press m or M to access MullFloat Menu," << endl
<< "Press q or Q to terminate the program." << endl;
}
void SubIntegers(void)
{
int x, y;
{
cout << "Enter two integers to compare" << endl;
getInteger();
getInteger();
displayIntegers(x, y);
}
}
int getInteger(void)
{
int x;
cin >> x;
return x;
int y;
cin >> y;
return y;
}
void displayIntegers(int n1, int n2)
{
cout << "x=" << n1 << endl
<< "y=" << n2 << endl
<< "The difference of the two integers is " << (n1 - n2) << endl;
}