hi guys i need some help how can i make those questions randomized when its played. i am a newbie and in my first year college. please suggest or comment some things that i can do to improve my work. thanks.
Code:
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#define pf printf
#define sf scanf
main()
{
char name[100],yrs[100];
int n,letter;
textcolor(BLACK);
textbackground(WHITE);
clrscr();
pf("\n===========================================================================");
pf("\n* Please Fill Up The Following *");
pf("\n*=========================================================================*");
pf("\n* *");
pf("\n* Enter Your Name: *");
pf("\n* *");
pf("\n* Enter Your Course: *");
pf("\n* *");
pf("\n===========================================================================");
gotoxy(40,6);
sf("%s",&name);
gotoxy(40,8);
sf("%s",&yrs);
clrscr();
pf("\n===========================================================================");
pf("\n| *Coded by:BSEMC-1A S Y 2016* |");
pf("\n|-------------------------------------------------------------------------|");
pf("\n ");
pf("\n ------- WELCOME %s TO QUIZ GAME! -------- ",name);
pf("\n ");
pf("\n|-------------------------------------------------------------------------|");
pf("\n| LOADING PLEASE WAIT... |");
pf("\n=========================================================================== ");
delay (60);
clrscr();
pf("\nPlayer :%s Course:%s",name,yrs);
pf("\n============================================================================== ");
pf("\t\t ----CHOOSE YOUR MODE----");
pf("\n 1.....................................EASY");
pf("\n 2.....................................MEDIUM");
pf("\n 3.....................................DIFFICULT");
pf("\n\n PLEASE ENTER YOUR CHOICE: ");
pf("\n============================================================================== ");
gotoxy(42,9);
sf("%d",&letter);
switch (letter);
{
char a,b,c;
int x=0
;
clrscr();
pf("\nPlayer :%s Course:%s",name,yrs);
pf("\n============================================================================== ");
pf("\nEASY MODE ..................................................Question 1 ot of 10");
pf("\n============================================================================== ");
pf("\nWhat did the ancient Greeks use instead of soap ?");
pf("\nA.Olive Oil\nB.coconut\nC.Nectar\nD.Butter");
pf("\n\n Your answer: ");
sf("%s",&a);
if (a=='a' || a=='A')
{
x=x+1;
printf("\n CORRECT! \n");
}
else
pf("\n WRONG! The Correct Answer Is A");
getch();
clrscr();
pf("\nPlayer :%s Course:%s",name,yrs);
pf("\n============================================================================== ");
pf("\nEASY MODE .................................................Questions 2 ot of 10");
pf("\n============================================================================== ");
pf(" Which Apollo mission landed the first humans on the Moon?");
pf("\nA.Apollon 7\nB.Apollo 9\nC.Apollo 11\nD.Apollo 13");
pf("\n Your Answer: ");
sf("%s",&b);
if (b=='c' || b=='C')
{
x=x+1;
printf("\n CORRECT! \n");
}
else
pf("\n WRONG! The Correct Answer Is C");
getch();
clrscr();
pf("\nPlayer :%s Course:%s",name,yrs);
pf("\n============================================================================== ");
pf("\nEASY MODE .................................................Questions 3 ot of 10");
pf("\n============================================================================== ");
pf("\n Who plays Lara Croft in the Tomb Raider series of films?'");
pf("\n A.Angelina Jolie\nB.Minnie Driver\nC.Nell McAndrew\nD.Jennifer Aniston");
pf("\n Your Answer: ");
sf("%s",&c);
if (c=='a' || c=='A')
{
x=x+1;
printf("\n CORRECT! \n");
}
else
pf("\n WRONG! The Correct Answer Is A");
clrscr();
if (x==30)
pf("\n PERFECT SCORE!:%d \n",x);
else if (x<30)
pf("\n YOUR TOTAL SCORE IS: %d OUT OF 3",x);
sf("%d",&letter);
}
getch();
return 0;
}
thanks guys..