James Hurray: How to make a quiz program in turbo pascal?
I need to make a quiz with 30 question (15 multiple choice, 15 cloze questions), and have the order of all questions randomized. It also must calculate the result as a percent and display the qeustions answered wrongly with the correct answer. Even just a sample with 3 or 4 example questions would be fine. I can almost do it, but i cant seem to randomize the order, and so that I dont get the same question appearing more than once.
Answers and Views:
Answer by na
Hi there,
It just so happens that I have a quiz program already written that does exactly what you want. The only problem is that I’m not going to be able to post it on here, since Yahoo Answers will a) truncate lines with … b) truncate the program code if it is too long c) remove all the formatting from the source code.
I will post a sample below (this may help you out), but if not, and you want the source code, feel free to mail me on [email protected] and I’ll send it to you via return mail.
BTW: the best way of randomizing the order of the questions and possible answers is to use an array of integers (each integer represents the index of the question or answer, as you may see from the code.
na
—– listing —–
Program Quiz;
uses crt;
var Quests: array[0..49] of string[50]; {array of questions in given language}
Ans: array [0..49,0..3] of string[20]; {multi-dimentional array 0-99 x 4}
rQ: array[0..49] of integer; {random questions order}
Scores: array[0..9] of string; {TOP 10, score board display data}
SelLang: integer; {current selected language, 0=En,1=Ge,2=Fr,3=It}
v,c,Qc,Qa: Integer; {Qc is “Question Count”=nuber of loaded questions, Qa=Quests Asked}
PlayersName: string; {players name, used in scoreboard}
…lots of code…
procedure Exists(r: Integer; a: array of Integer; var res: boolean);
var i: Integer;
begin
{check for value in array}
res:=False; i:=low(a);
while (i
Leave a Reply