Chalange #2

+4 Thalinda Bandara · August 11, 2015
#include
#include
#include
#include

main(){

int diceroll1,diceroll2,diceroll3,sum=0,sum1;
int rolls;
char high;


    diceroll1=(rand()%6)+1;
    diceroll2=(rand()%6)+1;
    diceroll3=(rand()%6)+1;
printf("%d\n",diceroll1);
printf("%d\n",diceroll2);
printf("%d\n",diceroll3);

sum=diceroll1+diceroll2+diceroll3;
printf("%d\n\n\n",sum);

printf("Pleace Enter you input with simpl letters/n");
scanf("%c",&high);


    diceroll1=(rand()%6)+1;
    diceroll2=(rand()%6)+1;
    diceroll3=(rand()%6)+1;
printf("%d\n",diceroll1);
printf("%d\n",diceroll2);
printf("%d\n",diceroll3);
sum1=diceroll1+diceroll2+diceroll3;
printf("%d\n",sum1);




if(high=='h'&&sum>sum1){
        printf("Good Gues it's high value");
}
else if(high=='l'&&sum

Post a Reply

Replies

- page 2
Oldest  Newest  Rating
0 Toyen . · August 14, 2015
Hey there again :)

The first part of the program I posted earlier now works but not properly.

The idea behind the do function was that if the user does not press "r", then keep asking the user to press "r".

Once they press r, then the dice rolls for the first time.

BUT

even when I press "r", it keeps looping asking me to press r.

What did I do wrong?

In the while statement I specified that while roll does not equal r, then keep looping the do statement.

Once roll is equal to "r", it should stop looping and roll the dice but this doesnt happen.
0 Thalinda Bandara · August 14, 2015
you can look new programm in here use this site to upload     http://ideone.com/pW8tc3
0 Thalinda Bandara · August 14, 2015
hi frend thanks for commenting.  in your programm there are some missing semicolans and i think there more actualy i can't see you code like this so if you can pleace upload as i upload. and i can't understand why are you using do while loop in there. k i have created the program using your logic k see is it doing what you wanted
0 Toyen . · August 14, 2015
Congrats! I am trying to complete this challenge myself but no luck so far.

I am trying to print the first roll but its not working.

Here it is:

/images/forum/upload/2015-08-13/d43cd19d6979281316ba402ead30de18.png

Basically, until the user enters r to roll the dice, I will keep asking him to roll it. Thats what I was trying to do here.

And if he enters r, the dice rolls for the first time.
0 Thalinda Bandara · August 11, 2015
http://ideone.com/TlBK0d get my code in here
  • 1
  • 2

C

126,722 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator