Dice Roll, I could not find the problem, ?'m waiting for your helps

0 Ahmet Semi Asarkaya · September 7, 2015
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>  
#include <string.h>
#include <math.h>
#include <time.h>


int main()
{
srand(time(NULL));
char  guess,s,l,h;
int sum[1111],sum1[1111],i;
printf("\tGUSS THE NEXT ONE\n");
printf("Guess whether the next roll is going to be higher, lower or stay the same");
printf("Higher ---> h\n");
printf("Lower  ---> l\n");
printf("Same   ---> s\n\n\n");

for(i=0; i<1111; i++)
{
sum=3+rand()%15;    
        printf("Dices rolls' sum is %d\n\n",sum);
    
        sum1=3+rand()%15; 

      printf("Guess about the next dices rolls\n\n\t:"); scanf("%c",&guess);

if(guess=='s' && sum==sum1)
{   
   printf("\n\nThe Next Dices rolls' sum is %d\n\n",sum1);
printf("\n\nCongralations!!! You Won the game!!!\n\n\n\n\n\n");
}
else if(guess=='h' && sum<sum1)
{
printf("\n\nThe Next Dices rolls' sum is %d\n\n",sum1);
printf("\n\nCongralations!!! You Won the game!!!\n\n\n\n\n\n");
}
else if(guess=='l' && sum>sum1)
{
printf("\n\nThe Next Dices rolls' sum is %d\n\n",sum1);
printf("\n\nCongralations!!! You Won the game!!!\n\n\n\n\n\n");
}
    else
    {
    printf("\n\nThe Next Dices rolls' sum is %d\n\n",sum1);
    printf("\n\nWrong Answer .....\nYou Lost\n\n\n\n\n\n");
}
}
    

return 0;
}

Post a Reply

Replies

Oldest  Newest  Rating
0 Jon Z. · September 8, 2015
Please in the future specify what's the problem (doesn't compile, gives wring output, etc).

you are using sum arrays, they should be just variables, or at least specify which element of the array you are using (sum).
also chars s, l and h are unnecessary.
  • 1

C

107,193 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator