Author |
Message |
YasserSalama
|
Posted: Mon May 12, 2008 5:16 pm Post subject: using arrays |
|
|
hey guys, what i am doing is creating a multiple choice test. i have decided to use arrays for this. what i have going on right now is that i have an array for the questions, 0 to 14, and an array for the correct answers also 0 to 14. What i want is to have the choices to be in an array, but how do i make it display 4 at a time for just one index? if more info is needed i'll be glad to put it out.. i know this description isn't really great so just ask! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Mon May 12, 2008 6:42 pm Post subject: RE:using arrays |
|
|
you can either use records, so that each index holds a custom type. Or your array can be 4 times as big, and you just keep in mind that index increments by four. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
YasserSalama
|
Posted: Mon May 12, 2008 7:05 pm Post subject: Re: using arrays |
|
|
thanks for the help! i am not that good so how would i go about making the array four times as big and then using the increments of 4? wouldn't it just skip 3 and output the fourth? |
|
|
|
|
|
I Smell Death
|
Posted: Fri May 16, 2008 9:12 am Post subject: Re: using arrays |
|
|
tony said that you could do this
Turing: |
type ans:
record
question:string
option :array 1..4 of string
answer:int
correctAnswer:int
end record
var question:array 0..14 of ans
function poseQuestion (which:int):boolean
put question(which).question
for a:1..4
put question(which).option(a)
end for
get question(which).answer
if question(which).answer=question(which).correctAnswer then
result true
end if
result false
end poseQuestion
question(0).question:="What colour is the sky???"
question(0).option(1):="1) Red"
question(0).option(2):="2) blue"
question(0).option(3):="3) green"
question(0).option(4):="4) none of the above"
question(0).correctAnswer:=2
put poseQuestion(0)
|
|
|
|
|
|
|
riveryu
|
Posted: Fri May 16, 2008 7:11 pm Post subject: RE:using arrays |
|
|
er "I Smell Death", I think you gave too much of a hint here... |
|
|
|
|
|
|