Click here to Skip to main content
14,389,876 members
Rate this:
Please Sign up or sign in to vote.
See more:
I HAVE TO DEVELOP A QUIZ PROGRAM IN C LANGUAGE SUCH AS IT SHOULD ASK RANDOM QUESTION FROM A PREDEFINED TEXT FILE WHICH WILL STORE QUESTIONS,OPTIONS,CORRECT ANSWER AND MARKS ALLOTED WITH THE HELP OF STRUCTURES AND AT LAST WE HAVE TO DISPLAY TOTAL MARKS FOR THE USER???

What I have tried:

I TRIED IT WITH THE HELP QUESTIONS DECLARED IN CODE ONLY BUT NOT FROM A PREDEFINED TEXT FILE
Posted
Updated 11-Jun-19 21:03pm
Comments
F-ES Sitecore 11-Jun-19 11:52am
   
WE'RE NOT HERE TO DO YOUR HOMEWORK FOR YOU.
Rick York 11-Jun-19 12:19pm
   
You might have better success if you STOP YELLING AT US!!!
Member 14494789 11-Jun-19 14:26pm
   
Sorry didn't know that all capitals mean something like that.
Rick York 11-Jun-19 16:09pm
   
To me, it means other things actually, but I was trying to be polite.
Richard MacCutchan 11-Jun-19 12:40pm
   
So start by designing the structure of your text file.
Patrice T 11-Jun-19 13:03pm
   
AND YOU HAVE A QUESTION ?
SHOW CODE AND STATE YOUR PROBLEM.
Rate this:
Please Sign up or sign in to vote.

Solution 1

1) DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.
2) We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

Working with structures is fine and you read text files like in this reading a textfile line for line example is shown.

Be sure that you provide enough memory for the read text. If you know its maximal length you can use some static buffer else you need to malloc it. Dont ferget to free it.

Use the random function like here shown.

On further question show always the written code.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Sorry I didn't know that all capitals mean something like that.

Firstly i declared 2 structures one for question and other for user.Structure for questions include variables like questionId , question,options,correct answer,and marks alloted and also total marks.My doubt is that do i have to input questions and other variables using user input or do I have to use fputs function for that???
   
Comments
Richard MacCutchan 11-Jun-19 14:52pm
   
The fputs function is for writing out to a file.

You should think aboot the steps required to make the quiz to work:
1. Read the questions and their answers from the file into a some form of array of structures, or simple arrays.
2. Get the basic input from the user, e.g. name, skill level etc.
3. Use a random function to select the next question, and display it.
3a. you may wish to display the possible answers at this point.
4. Get the user's answer.
5. Check if the answer is correct:
5a. Add to the score of correct or wrong answers.
5b. If necessary repeat the question until the correct answer, or a fixed number of times.
6. Go back to step 3 and repeat until the quiz is over.
Patrice T 11-Jun-19 17:55pm
   
Use Improve question to update your question.
So that everyone can pay attention to this information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100