Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please provide an easy to follow C langauge program for this. I am having a hard

ID: 3749001 • Letter: P

Question

Please provide an easy to follow C langauge program for this. I am having a hard time with it. Thank you

11.3 Lab week 4- How many Die Create a program that will prompt the user for the number of die (between 0 and 3) that the user would like the computer to roll. Based on that input, and using if-else statements output the appropriate number of die values (between 1 and 16, we have fancy dice), and sum up the values appearing on the die. For example, here are a few executions: Please enter the number of die to be rolled: 2 The two die have values of 7 and 12, for a total of 19 Please enter the number of die to be rolled: 5 We can only roll at most 3 dice. Please enter the number of die to be rolled: -2 Number of die to be rolled must be greater than O There are three test cases just to get you started, the remaining 7 points will consist of formatting 2pts, comments 2pts, variable names 1pt, random numbers working properly (should get different die values everytime program is run) 2 points. For a total of 10 points LAB ACTIVITY 11.3.1: Lab week 4- How many Die 0/3 main. Load default template... #include 2 include 3 #include int main) 18

Explanation / Answer

#include #include #include int main() { srand(time(NULL)); // random number generator int n, d1, d2, d3; printf("Please enter the number of die to be rolled: "); scanf("%d", &n); if(n 3) { printf("We can only roll at most 3 dice. "); } else { if(n == 1) { d1 = 1 + (rand() % 16); printf("The one die have value %d, for a total of %d. ", d1, d1); } else if(n == 2) { d1 = 1 + (rand() % 16); d2 = 1 + (rand() % 16); printf("The two dice have values %d and %d, for a total of %d. ", d1, d2, d1+d2); } else { d1 = 1 + (rand() % 16); d2 = 1 + (rand() % 16); d3 = 1 + (rand() % 16); printf("The three dice have values %d, %d and %d, for a total of %d. ", d1, d2, d3, d1+d2+d3); } } return 0; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote