Challenge 2!!! Completed

0 Nishant Tadvi · December 26, 2014

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <time.h>
int main()
{
    int dice1, dice2, dice3;
    int total1, total2;
    char estimate, inreal;

    srand(time(NULL));

    dice1 = (rand() % 6) +1;
    dice2 = (rand() % 6) +1;
    dice3 = (rand() % 6) +1;

    printf(" Your Dice get %d %d %d, \n", dice1,dice2,dice3 );
    printf(" The total of all Three is %d \n", total1);

    total1 = dice1+dice2+dice3;

    printf(" Estimate the Number Will be : (H)igher , (L)ower , (S)ame? : ");
    scanf(" %c", &estimate);

    if( total1 == total2 ){
         inreal = 'S';
    }
    else if( total1 > total2 ){
         inreal = 'H';
    }else{
         inreal = 'L';
    }

    (estimate == inreal) ? puts("You are Right ..... YOU WIN!!!!") : puts("You are Wrong.....YOU LOSE!!!!");


    return 0;
}

Thx for seeing it . If you find Difficulty with this Just say me and also suggest me about some Changes .. Thx

Post a Reply

Replies

Oldest  Newest  Rating
0 Nishant Tadvi · December 29, 2014
Its okk to use it after also.
0 Darsh Patel · December 28, 2014
Good nishant but     total1    should be before these two sentences:

printf(" Your Dice get %d %d %d, \n", dice1,dice2,dice3 );
printf(" The total of all Three is %d \n", total1);
  • 1

C

107,342 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator