Wy am i getting this error message?

This is a discussion on Wy am i getting this error message? within the C++ Programming forums, part of the General Programming Boards category; Code: #include<iostream> #include<string> using namespace std; int main() { double money; string food; int quantity; double price = 1.25; double ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Location
    Seattle Washington
    Posts
    20

    Wy am i getting this error message?

    Code:
    #include<iostream>
    #include<string>
    
    using namespace std;
    
    int main()
    {
    	double money;
    	string food;
    	int quantity;
    	double price = 1.25;
    	double total;
    	char reply = 'y';
    
    
    	do
    	{
    		cout << "Enter Food:";
    		getline(cin,food);
    
    		if (food == "tacos")
    		{
    			cout << "How Many: ";
    			cin >> quantity;
    
    			total = price * quantity;
    
    			cout << "Total :"<< total<<endl;
    
    			cout << "More Items: ";
    			cin >> reply;
    		} 
    	
    
    		else
    		{
    			cout << "No Item Found" <<endl;
    		} while (reply == 'y' || reply == 'Y');
    	}
    
    	return 0;
    
    }
    error message
    Code:
    error C2059: syntax error : 'return'

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Count your curly braces.

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Your while is also in the wrong place.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21