i cant random the question
i have 10 question and only 5 question will appear in one category since that is not complete
i hope anyone can help me to random the question
im only beginner..
here my sample code
Code:
# include <stdio.h>
# include <stdlib.h>
int score;
main()
{
char cat;
clrscr();
printf ("Welcome to Trivia");
getch();
back1:
clrscr();
printf ("\n");
printf (" Select Category\n");
printf ("\n");
printf ("\n");
printf ("\n");
printf ("\n");
printf (" [A] HISTORY\n");
printf ("\n");
printf (" [B] GENERAL KNOWLEDGE\n");
printf ("\n");
printf (" [C] ENGLISH\n");
printf ("\n");
printf (" [D] SCIENCE\n");
printf ("\n");
printf (" [E] QUIT\n");
printf (" Enter a category: ");
scanf ("%c",&cat);
switch (cat)
{
case 'A':history();break;
case 'a':history();break;
case 'B':;break;
case 'b':;break;
case 'C':;break;
case 'c':;break;
case 'D':;break;
case 'd':;break;
case 'E':;break;
case 'e':;break;
}
goto back1;
}
history ()
{
char ans;
int ok=0,clr=0,q;
clrscr();
printf ("\n\n\n HISTORY\n");
getch();
back:
clrscr();
clr++;
q=random(1);
printf ("%d",q);
getch();
switch (q)
{
case 0:
if (ok != 1)
{
printf ("\nWho is the first to discover PAPER?\n\n\n");
printf ("[A] India [C] Egypt\n\n");
printf ("[B] China [D] none of the above\n");
printf (" Answer: ");
scanf ("%c",&ans);
switch (ans)
{
case 'B':break;
case 'b':break;
default :break;
}
printf ("%d",clr);
if (clr >= 10)
{
getch();
main();
++ok;
}
else
{
goto back;
++ok;
}
break;
}
case 1:
if (ok != 1)
{
printf ("\nWhat is the first to discover PAPER?\n\n\n");
printf ("[A] India [C] Egypt\n\n");
printf ("[B] China [D] none of the above\n");
printf (" Answer: ");
scanf ("%c",&ans);
switch (ans)
{
case 'B':break;
case 'b':break;
default :break;
}
printf ("%d",clr);
if (clr >= 10)
{
getch();
main();
++ok;
}
else
{
goto back;
++ok;
}
}
break;
}
}
thanks for help..