2 Replies - 243 Views - Last Post: 29 December 2011 - 12:54 PM Rate Topic: -----

#1 saljanjan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 13-December 10

syntax error ' return'

Posted 29 December 2011 - 11:41 AM

#include <iostream>
using namespace std;

int main()
{
	int num;
	char reply;
	do
	{
	cout << " Please enter a positive integer between 59 and 78 "<< endl;
	cin >> num;

	if(num >= 58 && num <=78){
		cout << " YOU WIN " << endl;
	}
	else
	{
		cout << " YOU LOSE " << endl;
	}
	cout << " Do you want to try another number again " << endl;
	cout << " enter 'Y' or 'y' to continue " << endl;
	cin >> reply;

	while(reply == 'Y' || reply == 'y');
	}

	//cin.get();
	//cin.ignore();
	return 0;


}

Is This A Good Question/Topic? 0
  • +

Replies To: syntax error ' return'

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: syntax error ' return'

Posted 29 December 2011 - 11:44 AM

You can't have return 0; outside of a function. Fixing your indentation and using sane indentation practices would help you spot this error immediately.
Was This Post Helpful? 1
  • +
  • -

#3 AKMafia001  Icon User is offline

  • </code.in.dream>

Reputation: 187
  • View blog
  • Posts: 624
  • Joined: 11-June 11

Re: syntax error ' return'

Posted 29 December 2011 - 12:54 PM

You first have to close the body of the do while loop then write down the while condition.

} while(reply == 'Y' || reply == 'y');


Was This Post Helpful? 2
  • +
  • -

Page 1 of 1