If I had the program:
I compile it and get the a warning sayingCode:#include <iostream> using namespace std; void getItemPrice() { int price; // making sure cost is not negative do { cout << "Enter cost of item (in cents) :" << endl; cin >> price; } while (price <= 0); // making sure cost is a multiple of 5 while ((price%5)!=0) { cout << "Price of item must be multiple of 5 cents." << endl; cout << "Enter cost of item (in cents) :" << endl; cin >> price; // again making sure cost is not negative while (price <= 0) { cout << "Enter cost of item (in cents) :" << endl; cin >> price; } } return price; } int main(); { int price; price = getItemPrice(); }
In function 'void getItemPrice()':
return-statement with a value, in function declared with a void return
type
I'm just wondering why I am unable to return the value of price from my getItemPrice function back to the main function. I know the series of commands inside getItemPrice work because I copied and pasted it from the previous assignment that we are building off of.
Thanks



LinkBack URL
About LinkBacks



