Question

Hi, I need a program in C, where it will prompt a user for a math...

Hi, I need a program in C, where it will prompt a user for a math quiz, either easy or medium. If the user choses difficulty easy, it will prompt the user for how many questions they would like from 1-5. If the user enters medium it will prompt the user on how many questions they would like from 1-10. After those prompts are entered questions will be displayed using rand(), the questions must be multiple choice or division, aswell different questions each time, if the user gets the correct answer it will say good job your right, and if the user inputs the wrong value it will show them the correct value. After all the questions are answer it will give them a total score out of however many questions they chose to do, as well a percentage. After that is displayed it will prompt the user to try another quiz, if yes it will repormpt the difficulty they want and so on... but if they enter no the program ends.

-only display mutiplication and division questions and they must be different each time/each quiz. as well for the division their cant be a 0 in the equation.

example out put:

Welcome to quiz

Please Enter 1 for easy or 2 for medium

1

Please Enter How many questions you would like on the quiz(1-5)

2

What is 8*10

80

Your correct!

What is 10/2?

3

Inccorect!

The Correct value is 5

Your score is 1/2

Your Percent is 50%

Would You like to try another Quiz(Y/N)

Y

Welcome to quiz

Please Enter 1 for easy or 2 for medium

.... and so on but if the user enters N the program would end.

Another example out put for medium

Welcome to quiz

Please Enter 1 for easy or 2 for medium

2

Please Enter How many questions you would like on the quiz(1-10)

6

What is 8*10

80

Your correct!

What is 10/2?

3

Inccorect!

The Correct value is 5

What is 1*30

30

Your correct

what is 5*10

50

Your Correct

What is 60/2

30

Your correct

What is 80*10

800

Your correct

Your score is 5/6

Your Percent is 83%

Would You like to try another Quiz(Y/N)

N

Homework Answers

Answer #1

Here you go:

#include <stdio.h>

#include<stdlib.h>

int main() {

int Answer_count;

int Question_count;

char choice1;

int percentage=0;

int ch,ch1,n;

do{

Answer_count=0;

Question_count=0;

ch1=0;

char new1='Y';

printf("Welcome to quiz\n");

printf("Please Enter 1 for easy or 2 for medium\n");

scanf("%d",&ch);

if(ch==1){

printf("Please Enter How many questions you would like on the quiz(1-5)\n");

scanf("%d",&n);

}

if(ch==2){

printf("Please Enter How many questions you would like on the quiz(1-10)\n");

scanf("%d",&n);

}

while(n>0){

int a=rand()%100;

int b=rand()%100;

int result=a*b;

int ans=0;

printf("What is %d*%d\n",a,b);

scanf("%d",&ans);

Question_count+=1;

if(ans==result)

{

printf("Your Correct\n");

Answer_count+=1;

}

else{

printf("Incorect!\n");

}

--n;

if(n>0){

int x=rand()%100;

int y=rand()%10;

int result1=x/y;

int ans1=0;

printf("What is %d/%d\n",x,y);

scanf("%d",&ans1);

Question_count+=1;

if(ans1==result1)

{

printf("Your Correct\n");

Answer_count+=1;

}

else{

printf("Incorect!\n");

}

--n;

}

}

printf("Your score is %d/%d\n",Answer_count,Question_count);

percentage=(((float)Answer_count/Question_count)*100);

printf("Your percent is %d%%\n",percentage);

printf("Would You like to try another Quiz(Y/N)\n");

scanf(" %c",&choice1);

if(choice1==new1)

{

ch1=1;

}

else{

ch1=0;

}

}while(ch1);

return 0;

}

Check the image below for code structure and output:

========================================================

A sign of thumbs up would be appreciated.

Know the answer?
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
Similar Questions
Assembler lanaguage program   The program is to prompt the user to enter a number between 2...
Assembler lanaguage program   The program is to prompt the user to enter a number between 2 and 100. Reject any invalid user inputs and terminate the program if invalid inputs are entered. Print each even number from 2 to the user entered number. Sum these even numbers and print the sum. Print each odd number from 1 to the user entered number. Sum these odd numbers and print the sum. Exit the program when the output is complete. The output...
In C++ write a program for a multiplication table It must Prompt the user for two...
In C++ write a program for a multiplication table It must Prompt the user for two integers between 1 and 20 (inclusive) • also must Calculates and displays the multiplication table in a well-formatted output The table must include a label for each row and column The program must follow the requirements: • Validates user input, displaying an error message and prompting to user to enter another integer if the input is invalid, and repeating it as many times as...
IN C++ PLEASE. Write a program where the user enters a number and you output an...
IN C++ PLEASE. Write a program where the user enters a number and you output an unfilled square of stars. (DO NOT PROMPT THE USER, just take in a number, The only console output should be the squares). For example the program would start with console input, The user would enters 3, you would output (note 3 is the lowest number your program will be tested with) *** * * *** or, The user enters 5, you would output *****...
Please use Python 3 4). Write a program that asks the user to enter 10 numbers....
Please use Python 3 4). Write a program that asks the user to enter 10 numbers. The program should store the numbers in a list and then display the following data: • The lowest number in the list • The highest number in the list •The total of the numbers in the list • The average of the numbers in the list   Sample input & output: (Prompt) Enter Number 1: (User enter) 4 (Prompt) Enter Number 2: (User enter) 7...
Write a C++ program that asks the user to enter in three numbers and displays the...
Write a C++ program that asks the user to enter in three numbers and displays the numbers in ascending order. If the three numbers are all the same the program should tell the user that all the numbers are equal and exits the program. Be sure to think about all the possible cases of three numbers. Be sure to test all possible paths. Sample Runs: NOTE: not all possible runs are shown below. Sample Run 1 Welcome to the order...
4) Write a Java program using Conditions: Write a program where it will ask user to...
4) Write a Java program using Conditions: Write a program where it will ask user to enter a number and after that it will give you answer how many digits that number has. Steps: 1) Create Scanner object and prompt user to enter the number and declare variable integer for input 2) Use if else condition with && condition where you will specify the digits of numbers by writing yourself the digit number that should display: Example(num<100 && num>=1), and...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do depending upon what the user enters, please refer to the examples below to use to test your program. Run your final program one time for each scenario to make sure that you get the expected output. Be sure to format the output of your program so that it follows what is included in the examples. Remember, in all examples bold items are entered by...
In C programming language please. -Construct a program that will make use of user defined functions,...
In C programming language please. -Construct a program that will make use of user defined functions, the do/while loop, the for loop and selection. -Using a do/while loop, your program will ask/prompt the user to enter in a positive value representing the number of values they wish to have processed by the program or a value to quit/exit. -If the user enters in a 0 or negative number the program should exit with a message to the user indicating they...
* Write a Java program that calculates and displays the Fibonacci numbers * First prompt the...
* Write a Java program that calculates and displays the Fibonacci numbers * First prompt the user to input a number, N * Then use a for loop to calculate and display the first N fibonocci numbers * For example, if the user enters 5, the output should be: * 1, 1, 2, 3, 5 * * if the user enters 10, the output should be: * 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
Write a program in Java that: 1. will prompt user with a menu that contains options...
Write a program in Java that: 1. will prompt user with a menu that contains options to: a. Add a To-Do Item to a todo list. A To-Do Item contains: i. An arbitrary reference number (4; 44,004; etc.) ii. A text description of the item ("Pick up dry cleaning", etc.) iii. A priority level (1, 2, 3, 4, or 5) b. View an item in the list (based on its reference number) c. Delete an item from the list (based...