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
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.
Get Answers For Free
Most questions answered within 1 hours.