SOLUTION: If you have 10 questions, and 2 choices per question, then I will have 3^10=59049 possible answer sheets. I would like to have a code in any programming language to generate for

Algebra.Com
Question 1058173: If you have 10 questions, and 2 choices per question, then I will have 3^10=59049 possible answer sheets.
I would like to have a code in any programming language to generate for me these answer sheets up to the last one.
e.g answer sheet 1 can look like;
1.A
2.C
3.A
4.A
5.B
6.C
7.C
8.A
9.A
10.B

Found 2 solutions by math_helper, ikleyn:
Answer by math_helper(2461)   (Show Source): You can put this solution on YOUR website!
The program to do 3 choices per question, with 10 questions, is below. Unlike the 2 choice version, this version uses an array to hold the current answer key and after printing the current key, it increments the first answer, if that goes past the 3rd choice, it resets that value back to 0 and carries over the change to the next entry (and so on until it reaches an entry that doesn't carry). In this way the array will walk across all possible answer keys.
………………………………………………. cut ……………………………………………...
#include stdio.h // surround stidio.h with less than, greater than
#include math.h // surround math.h with less than, greater than

int main(int argc, char **argv)
{
int i,j,k, key[10];
int n_max;
// Zero out the ans key, key[k]=0,1,2 ==> A,B,C respectively
for(k=0; k<10; k++) {
key[k] = 0;
}
n_max = (int)pow(3, 10);
// Next line is "for i equals 0 semicolon i less than n max semicolon i plus plus"
for(i=0; i
// Print ans sheet corresponding to key[]
printf("Ans sheet %d\n", i+1);
for(j=0; j<10; j++) {
printf("%2d. %c\n", j+1, key[j]+'A');
}

// Generate next ans key
for(k=0; k<10; k++) {
key[k]++;
if (key[k] > 2) {
key[k] = 0;
}
else {
// Exit loop once we have no more carries
break;
}
}
}

return 0;
}

Answer by ikleyn(52805)   (Show Source): You can put this solution on YOUR website!
.
The first phrase of this post

    "If you have 10 questions, and 2 choices per question, then I will have 3^10=59049 possible answer sheets. " 

is incorrect.

Also, the answer sheet does not correlate with this first phrase.


RELATED QUESTIONS

If you have 10 questions, and 2 choices per question, then I will have 3^10=59049... (answered by rothauserc)
If you have 10 questions, and 2 choices per question, then I will have 2^10=1024 possible (answered by math_helper)
A multiple choice exam consists of 12 questions, each having 5 possible answers. To pass, (answered by stanbon)
If you took a quiz with 10 questions, and there were 5 possible answers per question,... (answered by stanbon)
A student guesses blindly on a 20-question multiple choice test. If each question has 4... (answered by stanbon)
I am trying to help my son with some algebra. I am wanting to confirm the following... (answered by ankor@dixie-net.com)
Exhibit 4. A very short quiz has two multiple choice questions with first question... (answered by reviewermath)
Hi Professor: I have a question related to the probability, a stock price is currently (answered by greenestamps,ikleyn,pdream98)
Hi Professor: I have a question related to the probability, a stock price is currently (answered by greenestamps)