![]() |
| | #1 |
| Registered User Join Date: Feb 2010
Posts: 58
| while loop with int variables Code: b=0
c=0
while (num_chips>1)
{
num_chips=initial_number_of_chips-a-b-c;
cout<<"\n"<<player_2<<"it is your turn, please select how many chips you would like";
cin>>b;
while (b >(num_chips)/2 || b<1)
{
cout<<"\nplease enter a different value";
cin>>b;
}
if (b <=(num_chips)/2 || b>1)
{
num_chips=initial_number_of_chips-a-b-c;
cout<<"\nThere are"<<num_chips<<"left";
cout<<"\n"<<player_1<<"it is your turn. please select how many chips you would like";
cin>>b;
}
while (b>(num_chips)/2 || b<1)
{
cout<<"\nPlease enter a different value";
cin>>b;
}
if (b<=(num_chips)/2|| b>=1)
{
num_chips=initial_number_of_chips-a-b-c;
cout<< "there are"<<num_chips<<"chips left";
}
}
return 0;
}
Last edited by joeman; 02-07-2010 at 11:54 AM. |
| joeman is offline | |
| | #2 |
| Registered User Join Date: Nov 2007
Posts: 352
| If I'm understanding you right, I think you want to do something like Code: num_chips=num_chips-a-b-c; There are a number of other issues here, (what are a and c used for? some logic issues as well) but let's just focus on this first.
__________________ I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo |
| NeonBlack is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| NEED HELP READING FILE and PRINTING | geoffr0 | C Programming | 4 | 04-16-2009 05:26 PM |
| Drawing Program | Max_Payne | C++ Programming | 21 | 12-21-2007 05:34 PM |
| 30something GSOH seeks help with the basics of a minor programme | promsan | C Programming | 3 | 05-13-2007 08:55 AM |
| Game Won't Compile | jothesmo | C++ Programming | 2 | 04-01-2006 04:24 PM |
| My graphics library | stupid_mutt | C Programming | 3 | 11-26-2001 06:05 PM |