I'm writing a pennies game in which a player and the computer take coins from a pile until only one remains. The trouble is I keep getting an error saying "warning C4700: uninitialized local variable 'nuCoins' used" though I thought after the user input a value it would be.
Any help would be much appriciated.
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std ;
void main()
{
srand((unsigned)time(0)) ;
int number ;
int gameStrtNo ;
int lowest = 1, highest = 5 ;
int range =(highest - lowest) + 1 ;
for(int index = 0 ; index < 200 ; index++)
{
int randNo = lowest+int(range*rand()/(RAND_MAX + 1.0)) ;
cin >> gameStrtNo ;
int nuCoins = 50 - (number || randNo);
if (gameStrtNo <=5)
{
cout << "Player goes first!\n" ;
cout << "Pick between 1 and 5 coins.\n" ;
cin >> number ;
cout << "There are "<<nuCoins<<" left.\n" ; //ERROR HERE
}
else
{
cout << "Computer goes first!\n" ;
cout << "Computer picked "<<randNo<<" coins.\n" ;
cout << "There are "<<nuCoins<<" left.\n" ;
}
}
}