how to randomize the questions in quiz program

Page 1 of 1

3 Replies - 986 Views - Last Post: 06 October 2012 - 08:34 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=294491&amp;s=af0934b09565a35c61b5a0fde0ef4972&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 aakash2000

Reputation: 0
• Posts: 1
• Joined: 06-October 12

how to randomize the questions in quiz program

Posted 06 October 2012 - 02:54 AM

```/* Programming in C FINAL PROJECT */
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

char Q1;
char Q2;
char Q3;
char Q4;
char Q5;
char Q6;
char Q7;
char Q8;
char Q9;
char Q10;

int c,w;

main()

{
printf ("1-What is 1 + 1?\nA=1\nB=2\nC=3\nD=4\n");
scanf ("%c", &Q1);
if ((Q1 == 'B')||(Q1 == 'b'))
{c=c+1;
}
else
{
w=w+1;

}
printf ("2-What is 2 + 2?\nA=4\nB=2\nC=6\nD=8\n");
scanf ("%s", &Q2);
if ((Q2 == 'A')||(Q2 == 'a'))
{
c=c+1;
}
else
{
w=w+1;

}
printf ("3-What is 4 + 4?\nA=2\nB=6\nC=8\nD=9\n");
scanf ("%s", &Q3);
if ((Q3 == 'C')||(Q3 == 'c'))
{c=c+1;
}
else
{
w=w+1;

}
printf ("4-What is 4 + 7?\nA=2\nB=6\nC=2\nD=7\n");
scanf ("%s", &Q4);
if ((Q4 == 'D')||(Q4 == 'd'))
{c=c+1;
}
else
{
w=w+1;

}
printf ("5-What is 1 + 3?\nA=2\nB=4\nC=3\nD=7\n");
scanf ("%s", &Q5);
if ((Q5 == 'B')||(Q5 == 'b'))
{c=c+1;
}
else
{
w=w+1;

}
printf ("6-What is 1 + 6?\nA=7\nB=6\nC=5\nD=10\n");
scanf ("%s", &Q6);
if ((Q6 == 'A')||(Q6 == 'a'))
{   c=c+1;
}
else
{
w=w+1;

}
printf ("7-What is 3 + 9?\nA=8\nB=18\nC=17\nD=12\n");
scanf ("%s", &Q7);
if ((Q7 == 'D')||(Q7 == 'd'))
{c=c+1;
}
else
{
w=w+1;

}
printf ("8-What is 3 + 9?\nA=8\nB=18\nC=17\nD=12\n");
scanf ("%s", &Q7);
if ((Q7 == 'D')||(Q7 == 'd'))
{   c=c+1;
}
else
{
w=w+1;

}
printf ("7-What is 3 + 9?\nA=8\nB=18\nC=17\nD=12\n");
scanf ("%s", &Q7);
if ((Q7 == 'D')||(Q7 == 'd'))
{c=c+1;
}
else
{
w=w+1;

}
printf ("7-What is 3 + 9?\nA=8\nB=18\nC=17\nD=12\n");
scanf ("%s", &Q7);
if ((Q7 == 'D')||(Q7 == 'd'))
{   c=c+1;
}
else
{
w=w+1;

}
printf("\n\tTotal Score= %d\n",c);

getch ();

}
```

MOD EDIT: Added code tags. When posting code...USE CODE TAGS!!!

This post has been edited by JackOfAllTrades: 06 October 2012 - 03:12 AM

Is This A Good Question/Topic? 0

Replies To: how to randomize the questions in quiz program

• Saucy!

Reputation: 6246
• Posts: 24,014
• Joined: 23-August 08

Re: how to randomize the questions in quiz program

Posted 06 October 2012 - 03:13 AM

#3 Skydiver

• Code herder

Reputation: 6067
• Posts: 20,890
• Joined: 05-May 12

Re: how to randomize the questions in quiz program

Posted 06 October 2012 - 08:11 AM

Functions would also be useful. It's another topic that should have been covered.

#4 jimblumberg

Reputation: 5424
• Posts: 16,910
• Joined: 25-December 09

Re: how to randomize the questions in quiz program

Posted 06 October 2012 - 08:34 AM

I would imagine that loops and possibly structures were also covered.

Jim