I need a function (for part of a much bigger program) that displays two dice side by side. such as
@ @ @
@
@ @ @
But the function cannot be extensive, meaning i cannot just write out 36 instances. The function would intake an Int variables die1, die2 for the number to be rolled. Which comes from a random number generater in the main function.
The function does not have to be like below, but if you know how thatd be awesome too. A hint the question gives me is:
? ? ? ? ? ?
? ?
? ? ? ? ? ?
Your program can fill in each '?' appropriately with a '@' or a ' ' by using the conditional operator, ... ? ... : ... . (Or maybe use arrays of characters and sprintf().) And/or do further extensions that you devise — use your imagination! (;-)
What ive been working on is this, but it is too confusing and extensive.
Code:double dice(int die1, int die2) { int roll, total; double average; printf("+-------+ +-------+\n"); //then you can go into if statements that print for common rolls if(die1 == 5 || die1 == 6 || die1 == 4) { printf("| @ @ | "); if(die2 == 5 || die2 == 6 || die2 == 4) { printf("| @ @ |\n"); } if(die2 == 2 || die2 == 3) { printf("| @ |\n"); } if(die2 == 1) { printf("| |\n"); } } if(die1 == 2 || die1 == 3) { printf("| @ | "); if(die2 == 6) { printf("| @ @ |\n"); } if(die2 == 2 || die2 == 3) { printf("| @ |\n"); } if(die2 == 1) { printf("| |\n"); } } if(die1 == 1) { } return(roll); }