Question

question 2 in C programming pleasePE-05b-01 (Six-sider) write a counter-controlled program that prompts the user to enter the number of times n to roll a six-sided die. The program should print to the screen the iteration of the loop and result for each roll 1 ) How many times would you like to roll? 3 roll 6 6 5 1 2) PE 05b 02 (Flash Cards) Write a counter-controlled program that creates addition problems for an elementary kid to solve. The program should prompt the user for the number of problems n to attempt. The program should produce two random integer numbers that range from 0 S num S 9 and prompt the user for the answer. The program should verify the answer and print correct or wrong to the screen. A sample format for each problem is suggested below + 4 ans: 3) PE 05b 03 (Random Numbers Within a Range) Write a function that generates a random number within a specified range. The function should take the low and high numbers for the range as integer arguments (inclusive) and return a random integer number. Test your function using a simple loop and print at least 25 numbers to the screen 4) PE 05b 04 (Roll Two Dice) Write a function that generates a random number simulating the roll of two six-sided dice. The function should take no arguments and return a random number simulating a single roll of two six-sided dice Test the function in a simple loop and print at least 25 iterations to the screen 5) PE 05b 05 (Coin Toss) Write a function that simulates slipping a coim. The function should

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main() {
   int n, i, n1, n2, answer;
   printf("How many problems do you want to attempt: ");
   scanf("%d", &n);
   for(i = 0; i < n; ++i) {
      n1 = rand() % 10;
      n2 = rand() % 10;
      printf("     %d\n", n1);
      printf("   + %d\n", n2);
      printf("  -----\n");
      printf("ans: ");
      scanf("%d", &answer);
      if(answer == n1+n2) {
         printf("correct\n\n");
      } else {
         printf("wrong\n\n");
      }
   }
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
question 2 in C programming please PE-05b-01 (Six-sider) write a counter-controlled program that prompts the user...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program that prompts the user for the number for times the user wants...

    Write a C program that prompts the user for the number for times the user wants to flip a coin. Your program will flip a virtual coin that number of times and return the following: 1) The number of times heads occurred. 2) The number of times tails occured. Then take the coin flip program and modify the random number generator to roll a single 6-sided dice.   DO NOT DISPLAY THE RESULTS OF EACH ROLL. 1) Ask the user how...

  • c++ program Exercise #1: Index of the Minimum Write a function main() that prompts the user...

    c++ program Exercise #1: Index of the Minimum Write a function main() that prompts the user to input a positive integer n, then calls the function generate() which generates n random numbers in the range [11, 217] inclusive. The function main() also calls the function indexMin() which finds the smallest random number and its index. The function main() prints the random numbers and the two values produced by the function indexMin(). Sample input/output: How many integers: 9 The 9 random...

  • Prime Numbers Write a program that will determine whether a set of randomly-generated numbers are prime...

    Prime Numbers Write a program that will determine whether a set of randomly-generated numbers are prime numbers. To write your program, you will need to use the following programming features: The random library (module) A function A variable that will prompt the user to say how many random numbers the program should generate A for loop with a range function A randint function taken from the random library (module); the randint function takes two arguments – the beginning and the...

  • PLEASE complete each task in python Write a console program that prompts the user for the...

    PLEASE complete each task in python Write a console program that prompts the user for the desired sum, then repeatedly rolls two six-sided dice (using a Random or RandomGenerator object to generate random numbers from 1-6) until the sum of the two dice values is the desired sum. Here is the expected dialogue with the user: Desired sum: 9 4 and 3 = 7 3 and 5 = 8 5 and 6 = 1 1 5 and 6 = 11...

  • IN C language Write a C program that prompts the user to enter a line of...

    IN C language Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr andcreadLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate...

  • Write a program that prompts the user to enter a number within the range of 1...

    Write a program that prompts the user to enter a number within the range of 1 to 10 inclusive. The program then generates a random number using the random class: If the users guess is out of range use a validation loop (DO) to repeat the prompt for a valid number, If the users guess matches the random number tell them they win! If the users guess does not match the random number tell them they are wrong. Use a...

  • How to write python code that is a dice rolling function that generates random numbers. The...

    How to write python code that is a dice rolling function that generates random numbers. The dice rolling function takes two arguments: the first argument is the number of sides on the dice and the second argument is the number of dice. The function returns the sum of the random dice rolls. For example, if I call roll dice(6,2) it might return 7, which is the sum of randomly chosen numbers 4 and 3. It somewhere along the lines of:...

  • Summary: Write a C program that prompts the user to enter 2 positive integer numbers, display...

    Summary: Write a C program that prompts the user to enter 2 positive integer numbers, display the numbers in 3 formats. Then check, whether the larger of the 2 is evenly divisible by the smaller. Detail: Write a complete C program, more complex than the typical "hello world" program. Prompt the user to enter 2 integer numbers that are not negative. After either entry, display that number again. Print the smaller in hexadecimal, in decimal, and in octal format. Include...

  • c++ please (1) Write a program that prompts the user to enter an integer value N...

    c++ please (1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT