Write a program to find all the four-digit numbers that have this property. For
ID: 3542598 • Letter: W
Question
Write a program to find all the four-digit numbers that have this property.
For example, here's a number that fails the test: 1430. Add 14 to 30 to get 44, square 44 to get 1936, but this is not what we started with (i.e. 1430) so this number fails the test.
Write a program that outputs the probability of winning at the game of craps. The rules for the game of craps are:
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. If the sum is 7 or 11 on the first throw, the player wins. If the sum is 2, 3 or 12 on the first throw (called "craps"), the player loses (i.e. the "house" wins). If the sum is 4, 5, 6, 8, 9 or 10 on the first throw, then that sum becomes the player's "point". To win, you must continue rolling the dice until you "make your point". The player loses by rolling a 7 before making the point.
Explanation / Answer
#include #include #include #include int rollDice(void); int main(void){ int roll; int playersPoint=0; int targetPoint=0; int count; int winCount=0; //How many times did you win? int loseCount=0; //How many times did you lose? int i; int howManyTimes=0; //How many times do you want the game run? int rollCount=0; //This counts the number of dice rolled whole srand(time(0)); //You have to call srand once and under main!!! Not in rollDice() function!!! enum Gamestatus {WON,LOST,CONTINUE}; enum Gamestatus status; printf("Enter how many times to play the game:"); scanf("%d",&howManyTimes); for(i=1;iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.