I'm working on this project and I'm REALLY close, I'm just gettin a C2059 error and I have no idea why?

``````#include <iostream>
using namespace std;

int main()
{
int guess;
int die;
float total = 10;
char ans;
cout << "Welcome to Dice Roll!" << endl;
cout << "Your bank total is: \$" << total << ".00" << endl;
cout << "\nGuess the next roll! It costs \$1.00 to play!" << endl;
cout << "The correct guess nets you \$100.00!\n" << endl;
cin >> guess;

do
{
--total;
die = (int)(rand() % 6) + 1;

if(guess < 1 || guess > 6)
{
cout << "Invalid Input" << endl;
cout << "Try again? (Type 'Y' or 'N')" << endl;
cin >> ans;
}
if(guess == die)
{
cout << "Congratulations! The dice rolled a" << die <<  "You won \$100.00!" << endl;
cout << "\nYour bank total is: \$" << total + 100 << ".00" << endl;
cout << "Try again? (Type 'Y' or 'N')" << endl;
cin >> ans;
}
if (guess != die)
{
cout << "I'm sorry, but you lost and we now have your dollar." << endl;
cout << "\nYour bank total is: \$" << total << ".00" << endl;
cout << "Try again? (Type 'Y' or 'N')" << endl;
cin >> ans;
} while(ans == 'Y' || 'y');

if (ans != 'Y' || ans != 'y' || ans != 'N' || ans != 'n')
{
cout << "Invalid Input" << endl;
}
else
{
cout << "Thanks for playing! Your bank is \$" << total << ".00" << endl;
}
}
return 0;
}``````
``````1>Compiling...
1>Lab9.cpp
1>c:\users\stephon.stephon-pc\documents\visual studio 2008\projects\lab9\lab9\lab9.cpp(51) : error C2059: syntax error : 'return'``````

Where's the while for do loop?

## All 4 Replies

Where's the while for do loop?

its on line 40

But the closing brace for do loop is at line 51 ... the while should be after it.

Ah, that helped alot, dumb mistake by me, thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.