just do a minor tweak for your last code.
notice that I put the rolling dice part into another function to make it easier. this should do the trick :
cpp
#include <iostream>
#include <ctime>
using namespace std;
char die(char,int *);
int main(void)
{
int money = 10;
char exit='Y';
srand(time(0));
while(exit=='Y' || exit=='y'){
cout<<endl<<"Your bank is $" <<money<<endl;
exit = die(exit, &money);
};
cout<<endl<<"Thanks for playing your bank is $"<<money<<". Come back real soon"<<endl;
cin.get ();
return 0;
}
char die(char exit, int *money){
*money = *money-1;
int num;
int die;
die=(int)(rand()%6)+1;
cout<<endl<<"Please enter your guess for the next roll. It only costs $1.00 to play. If you are correct I will pay you $100.00:" <<endl;
cin>>num;
if (die == num)
{
cout<<"Winner. The dice rolled a "<<die<<endl;
*money += 100;
}
else if(die != num)
{
cout<<"Sorry. The dice rolled a "<<die<<endl;
}
cout<<"Press 'Y' to continue. Continue?"<<endl;
cin>>exit;
return exit;
}
you can ask here again if there's anything that you don't understand.
hope this helps you