Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include<time.h>
  4. #include<conio.h>
  5. int main()
  6. {
  7. printf("1. Play Game?\n2. Exit.\nEnter Choice: ");
  8. int n,a,b,c,d,e,f,g,rand1,rand2,rand3,ans;
  9. scanf("%d",&n);
  10. for(; n=1;)
  11. {
  12. start:
  13. srand(time(0));
  14. a = (rand() % 100);
  15. b = (rand() % 100);
  16. c = (rand() % 100);
  17. d = (rand() % 100);
  18. e = (rand() % 100);
  19. f = (rand() % 100);
  20. g = (rand() % 100);
  21. printf("First number: %d\nPress any key to proceed to the next number...\n",a);
  22. getch();
  23. printf("Second number: %d\nPress any key to proceed to the next number...\n",b);
  24. getch();
  25. printf("Third number: %d\nPress any key to proceed to the next number...\n",c);
  26. getch();
  27. printf("Fourth number: %d\nPress any key to proceed to the next number...\n",d);
  28. getch();
  29. printf("Fifth number: %d\nPress any key to proceed to the next number...\n",e);
  30. getch();
  31. printf("Sixth number: %d\nPress any key to proceed to the next number...\n",f);
  32. getch();
  33. printf("Seventh number: %d\nPress any key to proceed to the questions...\n",g);
  34. getch();
  35.  
  36.  
  37. while(1){
  38. rand1 = (rand() % 100);
  39. rand2 = (rand() % 100);
  40. rand3 = (rand() % 100);
  41. printf("What was the first number? %d %d %d %d\nAnswer: ",rand1,rand2,a,rand3);
  42. scanf("%d",&n);
  43. if(n==a)
  44. {
  45. printf("Correct!!!\n");
  46. }
  47. else
  48. {
  49. printf("Wrong Answer! Start from the first question!\n");
  50. continue;
  51. }
  52. rand1 = (rand() % 100);
  53. rand2 = (rand() % 100);
  54. rand3 = (rand() % 100);
  55. printf("What was the second number? %d %d %d %d\nAnswer: ",rand1,b,rand2,rand3);
  56. scanf("%d",&n);
  57. if(n==b)
  58. {
  59. printf("Correct!!!\n");
  60. }
  61. else
  62. {
  63. printf("Wrong Answer! Start from the first question!\n");
  64. continue;
  65. }
  66. rand1 = (rand() % 100);
  67. rand2 = (rand() % 100);
  68. rand3 = (rand() % 100);
  69. printf("What was the third number? %d %d %d %d\nAnswer: ",c,rand1,rand2,rand3);
  70. scanf("%d",&n);
  71. if(n==c)
  72. {
  73. printf("Correct!!!\n");
  74. }
  75. else
  76. {
  77. printf("Wrong Answer! Start from the first question!\n");
  78. continue;
  79. }
  80. rand1 = (rand() % 100);
  81. rand2 = (rand() % 100);
  82. rand3 = (rand() % 100);
  83. printf("What was the fourth number? %d %d %d %d\nAnswer: ",rand1,d,rand2,rand3);
  84. scanf("%d",&n);
  85. if(n==d)
  86. {
  87. printf("Correct!!!\n");
  88. }
  89. else
  90. {
  91. printf("Wrong Answer! Start from the first question!\n");
  92. continue;
  93. }
  94. rand1 = (rand() % 100);
  95. rand2 = (rand() % 100);
  96. rand3 = (rand() % 100);
  97. printf("What was the fifth number? %d %d %d %d\nAnswer: ",rand1,rand2,e,rand3);
  98. scanf("%d",&n);
  99. if(n==e)
  100. {
  101. printf("Correct!!!\n");
  102. }
  103. else
  104. {
  105. printf("Wrong Answer! Start from the first question!\n");
  106. continue;
  107. }
  108. rand1 = (rand() % 100);
  109. rand2 = (rand() % 100);
  110. rand3 = (rand() % 100);
  111. printf("What was the sixth number? %d %d %d %d\nAnswer: ",f,rand1,rand2,rand3);
  112. scanf("%d",&n);
  113. if(n==f)
  114. {
  115. printf("Correct!!!\n");
  116. }
  117. else
  118. {
  119. printf("Wrong Answer! Start from the first question!\n");
  120. continue;
  121. }
  122. rand1 = (rand() % 100);
  123. rand2 = (rand() % 100);
  124. rand3 = (rand() % 100);
  125. printf("What was the seventh number? %d %d %d %d\nAnswer: ",rand1,rand2,rand3,g);
  126. scanf("%d",&n);
  127. if(n==g)
  128. {
  129. printf("Congratulations! You won! Want to play again?\n1. Play Game?\n2. Exit.\n");
  130. scanf("%d",&n);
  131. if(n==1)
  132. {
  133. continue;
  134. }
  135. else
  136. {
  137. return 0;
  138. }
  139. }
  140. else
  141. {
  142. printf("Wrong Answer! Start from the first question!\n");
  143. continue;
  144. }
  145.  
  146.  
  147.  
  148. }
  149. }
  150.  
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement