Advertisement
Guest User

Untitled

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