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
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 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...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter 10 numbers. 2. save those numbers in a 32-bit integer array. 3. Print the array with the same order it was entered. 3. Calculate the sum of the numbers and display it. 4. Calculate the mean of the array and display it. 5. Rotate the members in the array forward one position for 9 times. so the last rotation will display the array in...
Write a program in C++ coding that asks the user to input an integer between 25...
Write a program in C++ coding that asks the user to input an integer between 25 and 50, inclusive. Utilize a WHILE loop to test for INVALID input. If the input is INVALID, the loop will repeat, and ask the user to try again. The pseudocode looks like this: Prompt user to input an integer between 25 and 50 Accept the input from the user Test for invalid input (HINT: use a while loop and the OR operator with 2...
in c++ Write a C++ program that asks the user to enter an integer number and...
in c++ Write a C++ program that asks the user to enter an integer number and prints it back "vertically" to the screen. Use recursion in your solution. As an example of how the program will work: Please enter an integer: 12345 The integer you entered will print vertically as: 1 2 3 4 5
/* This program should check if the given integer number is prime. Reminder, an integer number...
/* This program should check if the given integer number is prime. Reminder, an integer number greater than 1 is prime if it divisible only by itself and by 1. In other words a prime number divided by any other natural number (besides 1 and itself) will have a non-zero remainder. Your task: Write a method called checkPrime(n) that will take an integer greater than 1 as an input, and return true if that integer is prime; otherwise, it should...
MIPS ASSEMBLY Have the user input a string and then be able to make changes to...
MIPS ASSEMBLY Have the user input a string and then be able to make changes to the characters that are in the string until they are ready to stop. We will need to read in several pieces of data from the user, including a string and multiple characters. You can set a maximum size for the user string, however, the specific size of the string can change and you can’t ask them how long the string is (see the sample...
Write a C program that prompts the user to input as many unsigned(n) as the user...
Write a C program that prompts the user to input as many unsigned(n) as the user wants to type, terminated by non negative number You may assume without checking that when the user is supposed to type an unsigned, he nevertypes a double You may assume without checking that when the user is supposed to type an unsigned, he nevertypes a negative number. For each number the user types, output whether that number is prime or not. You won't need...
(8 marks) Write a program to ask user to input an integer and display the special...
Write a program to ask user to input an integer and display the special pattern accordingly. REQUIREMENTS The user input is always correct (input verification is not required). Your code must use loop statements (for, while or do-while). Your program should use only the following 3 output statements, one of EACH of the followings: System.out.print("-"); // print # System.out.print("+"); // print + System.out.println(); // print a newline Your code must work exactly like the following example (the text in bold...
Use C++ Write a program that first reads in how many whole numbers the user wants...
Use C++ Write a program that first reads in how many whole numbers the user wants to sum, then reads in that many whole numbers, and finally outputs the sum of all the numbers greater than zero, the sum of all the numbers less than zero (which will be a negative number or zero), and the sum of all the numbers, whether positive, negative, or zero. The user enters the numbers just once each and the user can enter them...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT