Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

What is the basic personal financial statement?

Answered: 1 week ago

Question

1. Think of proposals primarily as persuasive documents

Answered: 1 week ago

Question

3. The group answers the questions.

Answered: 1 week ago