I know its not allowed to post homework questions here unless i have most of the code done and i think i have done most of it so here goes me...:
Question:
The following C program
will print out 10 random integers.Code:#include<stdio.h> main() { int i; for (i=0; i<10;i++) printf("%10d \n",1+rand()%6); }
Therefore, the operation ofin the printf statement can be used toCode:1+ rand()%6
model the rolling a Six-Sided Die.
Write a complete C program to model the following game of rolling two dice:
A player rolls two dice. Each die has six faces. These faces contain 1, 2, 3, 4, 5
and 6 spots. After the dice have come to rest, the sum of the spots on the two
upward faces is calculated.
(i) If the sum is 7 or 11 on the first throw, the player wins.
(ii) If the sum is 2, 3, or 12 on the first throw, the player loses.
(iii) If the sum is 4, 5, 6, 8, 9 or 10 on the first throw, the sum becomes the
player’s point. To win, you must continue rolling the dice until you
make your point. However, the player loses by rolling a 7 before
making the point.
Sample runs for the game are as follows:
Player rolled 5 + 6 = 11
Player wins
Player rolled 4 + 1 = 5
Point is 5
Player rolled 6 + 2 = 8
Player rolled 1 + 2 = 3
Player rolled 3 + 2 = 5
Player wins
Player rolled 4 + 6 = 10
Point is 10
Player rolled 3 + 4 = 7
Player loses
Player rolled 1 + 1 = 2
Player loses
Code:
i know that the code is veeeery wrong and i dont know how to code properly as you see i dont know how to begin or end any help would be apreciated and the wors thing is that the assingment has 5 questions and this is the only one i know how to start so can i possibly post the rest of the questions to get help with them and the assingment is due next tuesday?Code:S.rand(time(NULL)) a= 1 + rand()%6; b= 1 + rand()%6; c= a + b if c= 7||11 printf("you win") else c= 2||3||12 printf("you lose") else c= 4||5||6||8||9||10 endif while{(f!=c) d= 1 + rand()%6; e= 1 + rand()%6; f= d + e if f= 7||11 printf("you lose")} printf("you win")
Thank you all in advance.