I love this place, I love my home, I love you.

 

C++ Literature Quiz Ver. 1.1 OUT!

So I am releasing the version 1.1 of the literature quiz code that I posted yesterday. After sharing it with some of the guys on twitter, I got a suggestion that I should use ‘switch’ to make my code look elegant.

And I did that. Plus, I added a scoring system too, have fun while playing it! :)

#include<iostream.h>

#include<conio.h>

void main()

{

 clrscr();

 int ch ,score=0;

 cout«”LITERATURE QUIZ!”;

 cout«”\n\nQ. Who wrote Oliver Twist?”;

 cout«”\n1. JK ROWLING    2. Charles Dickens    3. RL Stein”;

 cout«”\nAnswer: “;

 cin»ch;

 switch(ch)

 {

  case 1 : cout«”Wrong answer. Correct is 2.”;

  break;

  case 2 : cout«”Correct answer!”;

  score=score+10;

  break;

  case 3 : cout«”Wrong answer. Correct answer is 2.”;

  break;

  default: cout«”Invalid entry. Please answer only in 1, 2 or 3.”;

  break;

 }

 cout«”\n\nQ. Who wrote the Harry Potter series of books?”;

 cout«”\n1. JK Wowling    2. Surendra Singh    3. JK Rowling”;

 cout«”\nAnswer: “;

 cin»ch;

 switch(ch)

 {

  case 1 : cout«”Wrong answer. Correct answer is  3.”;

  break;

  case 2 : cout«”Wrong answer. Correct answer is 3.”;

  break;

  case 3 : cout«”Correct answer!”;

  score=score+10;

  break;

  default: cout«”Invalid entry. Please answer in 1, 2 or 3”;

  break;

 }

cout«”\n\nYou scored: “«score;

 if (score<=20)

  cout«”You can do well!”;

 else

  cout«”\nWell done!”

 getch();

}

Share it with your friends. And please do give me some more suggestion on how I can improve it. 

PS: Not a programmer? You can still view the quiz! Just download it from here - http://bit.ly/eEaBSG