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 /* srand, rand */

#include /* time */

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!