learning functions and I am having trouble with some local variables. I keep getting "warning C4700: uninitialized local variable 'y' used", same for the variable x. Are my loops in combinations with cin >> messing up the code? I am pretty new to programming, any help would be greatly appreciated. Heres the code:
Code:
#include <iostream>
using namespace std;
//function prototype
double calculateRetail(double, double);
int main()
{
double x, y, z;
while(x < 0)
{
cout << "This progam calculates and displays an items retail price. Enter the whole sale price...\n";
cin >> x;
}
while(y < 0)
{
cout << "Enter the markup percentage...\n";
cin >> y;
}
z = calculateRetail(x, y);
cout << z << " is the retail price.\n";
return 0;
}
double calculateRetail(double x, double y)
{
return x * y * .01;
}