Question
There are two erros in my programming. The first one called error C1010: unexpected end of file while looking for precompiled header. Did you forget
There are two erros in my programming. The first one called error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include"stdafx.h"' to your source? I attempted to add it, but it still does not work.
The second error is the Italics and Bold word in my programming, which said "IntelliSence: expression must have a constant value".
Does anybody can help me to figure out these two errors? I have no idea about them.
#include
#include
#include
using namespace std;
int RandomNumber()
{
srand (time(NULL));
return rand() % 12 + 2;
}
bool CheckWinner(int i)
{
return (i==50);
}
int main()
{
int noOfPlayer=0;
cout << "Enter number of Player" ;
cin >> noOfPlayer;
while(noOfPlayer < 2 || noOfPlayer > 4)
{
cout << "Please enter valid number of player" << endl;
cin >> noOfPlayer;
}
int spaces[50];
int playerPos[noOfPlayer];
for(int i=0;i
playerPos[i] = 0;
bool win = false;
int winner;
while(!win)
{
for(int j=0;j
{
cout << "Player " << j+1 << " turn move dice " << endl;
int num = RandomNumber();
switch(num)
{
case 2:
{
if(playerPos[j]+2 <= 50)
playerPos[j] += 2;
if(CheckWinner(playerPos[j]))
{
win = true;
winner = j+1;
}
break;
}
case 3:
{
if(playerPos[j]+3 <= 50)
playerPos[j] += 3;
if(CheckWinner(playerPos[j]))
{
win = true;
winner = j+1;
}
break;
}
case 4:
{
if(playerPos[j]-1 >=0)
playerPos[j] -= 1;
if(CheckWinner(playerPos[j]))
{
win = true;
winner = j+1;
}
break;
}
case 5:
{
if(playerPos[j]+25 <= 50)
playerPos[j] += 5;
if(CheckWinner(playerPos[j]))
{
win = true;
winner = j+1;
}
break;
}
case 6:
{
if(playerPos[j]+6 <= 50)
playerPos[j] += 6;
if(CheckWinner(playerPos[j]))
{
win = true;
winner = j+1;
}
break;
}
case 7:
{
int k=0;
while(k < noOfPlayer)
{
if(k != j && playerPos[k] > playerPos[j])
playerPos[j] = playerPos[k];
k++;
}
if(CheckWinner(playerPos[j]))
{
win = true;
winner = j+1;
}
break;
}
case 8:
{
if(playerPos[j]+8 <= 50)
playerPos[j] += 8;
if(CheckWinner(playerPos[j]))
{
win = true;
winner = j+1;
}
break;
}
case 9:
{
if(playerPos[j]+9 <= 50)
playerPos[j] += 9;
if(CheckWinner(playerPos[j]))
{
win = true;
winner = j+1;
}
break;
}
case 10:
{
if(playerPos[j]+10 <= 50)
playerPos[j] += 10;
if(CheckWinner(playerPos[j]))
{
win = true;
winner = j+1;
}
break;
}
case 11:
{
int k=0;
while(k < noOfPlayer)
{
if(k != j && playerPos[k] < playerPos[j])
playerPos[j] = playerPos[k];
k++;
}
if(CheckWinner(playerPos[j]))
{
win = true;
winner = j+1;
}
break;
}
case 12:
{
playerPos[j] = 0;
if(CheckWinner(playerPos[j]))
{
win = true;
winner = j+1;
}
break;
}
}
}
}
cout << " Winner is " << winner+1 ;
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started