Declare another variable cumilative_total which will hold the cumilative value.

Do something like this at the end of the inner while loop:

``````score = MAX_ATTEMPTS - attempts ;
cumilative_score += score ;
printf ("The score of this round is %d.", score) ;
score = 0 ; // reset the score``````

So I'm supposed to expand on this game and make it two player. I have modularised and I started on a rounds function that will take in each players' guess and the random number and carry out a round. The same rules apply except for the way the score is calculated

score = 5 * (total amount of attempts allowed - actual amount of attempts taken) *e5/timeTaken

for each player the total amount of attempts allowed is equal to five (5) and that the timeTaken is determined as the time interval between the user being prompted for his first guess and the end of the round. Since I am unfamiliar with the time function I was wondering how this would be implemented here is my rounds function.

``````void rounds (int rand int guess)
{
int attempts=1;
const int MAX_ATTEMPTS = 5;
int score;
int timetaken;

while(attempts <= 5)
{

if (rand==guess)
{
printf("Congratulations,You are correct!\n");
break;
}
if ((unsigned int)(rand-guess) >40)
{
printf("You are Cold\n");
}
else if (10<=(unsigned int)(rand-guess))
{
printf("You are Warm\n");
}
else if ((unsigned int)(rand-guess) < 10)
{
printf("You are Hot!\n");

}
++attempts;

}
score += 5*(MAX_ATTEMPTS - attempts)*exp(5.0)/timetaken ;/* Time based score above*/
printf("End of round,Your score is %d\n", score);

}``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.