Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4.  
  5. char *questions[10][5] = {
  6. { "What is the smallest unit in the computer system.", "Block", "Byte", "Bit", "C" },
  7. { "What is the most widely used device in the computer..", "Solid state disks", "Mouse", "Hard drive", "C" },
  8. { "WWW stands for.", "Wan Wide World.", "World Wide Web", "Wide Wan Web", "B" },
  9. { "What software is used to view web pages.", "Internet", "Web Browser", "Page Browser", "B" },
  10. { "Which one is a word processor.", "Notepad.", "Excel", "Word Perfect", "C" },
  11. { "How many bits are there in one byte.", "6", "8", "4", "B" },
  12. { "ISP stands for.", "International Service Provide", "Internet Service Printer", "Internet Service Provider", "C" },
  13. { "How many bytes are there in 2040 bits.", "255", "1024", "100", "A" },
  14. { "Every number system has a base, that is called", "Index", "Radix", "Subscript", "B" },
  15. { "A device that converts digital signals to analog signals is", "Packet", "Modem", "Block", "B" }
  16. };
  17.  
  18. const int QUESTIONS = 10;
  19.  
  20. int cur_question = 0;
  21. int Correct = 0;
  22.  
  23. void ShowQuestion(int index){
  24. printf("%s\n\n",questions[index][0]);
  25. }
  26.  
  27. void ShowAnswers(int qIndex){
  28. printf("%s\n\n",questions[qIndex][0]);
  29. printf("[A] %s\n",questions[qIndex][1]);
  30. printf("[B] %s\n",questions[qIndex][2]);
  31. printf("[C] %s\n",questions[qIndex][3]);
  32. printf("\nPlease enter a answer: ");
  33. }
  34.  
  35. void CheckAnswer(int qIndex, char Answer){
  36. if(questions[qIndex][4][0] == Answer){
  37. Correct++;
  38. }
  39. }
  40.  
  41. int main()
  42. {
  43. char Answer;
  44.  
  45. while(cur_question < QUESTIONS){
  46. //Show question
  47. //Show answers
  48. ShowAnswers(cur_question);
  49. //Get answer
  50. scanf(" %c",&Answer);
  51. printf("\n");
  52. //Convert to uppercase
  53. Answer = toupper(Answer);
  54. //Check answer.
  55. CheckAnswer(cur_question,Answer);
  56. //INC counter
  57. cur_question++;
  58. //Add a small line break
  59. }
  60.  
  61. if(Correct == 1)
  62. {
  63. printf("\nYou got %d answer correct\n",Correct);
  64. }else{
  65. printf("\nYou got %d answers correct\n",Correct);
  66. }
  67.  
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement