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

Algebra.Com
Question 1057864: If you have 10 questions, and 2 choices per question, then I will have 2^10=1024 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.True
2.False
3.True
4.True
5.False
6.True
7.True
8.False
9.False
10.False

Answer by math_helper(2461)   (Show Source): You can put this solution on YOUR website!

C program:
#include

int main(int argc, char **argv)
{
int i,j;

for(i=0; i<1024; i++) {
// Print ans sheet corresponding to i
printf("Ans sheet %d\n", i+1);
for(j=0; j<10; j++) {
printf("%2d. ", j+1);
if ((i & (1< printf(" True\n");
}
else {
printf(" False\n");
}
}
}
return 0;
}

RELATED QUESTIONS

If you have 10 questions, and 2 choices per question, then I will have 3^10=59049... (answered by math_helper,ikleyn)
If you have 10 questions, and 2 choices per question, then I will have 3^10=59049... (answered by rothauserc)
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)
I would like to know how to answer this probability question Weekly demand for an item (answered by Boreal)
A student guesses blindly on a 20-question multiple choice test. If each question has 4... (answered by stanbon)
Calculate the indicated value. f(x) = 7x - 27x^2 - 7 find f(-7) I'm not sure... (answered by jim_thompson5910)
Exhibit 4. A very short quiz has two multiple choice questions with first question... (answered by reviewermath)