Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1.  
  2. #include<time.h>
  3. #include <stdlib.h>
  4. #include <iostream>
  5. using namespace std;
  6. main()
  7. {
  8.  
  9.  
  10. //make sure no 2 numbers are the same
  11. srand(time(NULL));
  12. int randnum,randnum2,oper,ans,computerans,cor,in,loop;
  13. cout<<"10 question quiz 3 2 1 gooooo\n\n";
  14. cor=0;
  15. in=0;
  16. //the loop will stop after the 10 way around
  17. for (loop=1; loop<11; loop++)1
  18. {
  19.  
  20. oper=rand() % 3+1;
  21. //ceching if it is addition
  22. if (oper=1)
  23. {
  24. //setting numbers
  25. randnum=rand()% 100;
  26. randnum2=rand()% 100;
  27. //outputing numbers
  28. cout<<randnum<<"+"<<randnum2<<" enter your answer -> ";
  29. cin>>ans;
  30. //getting the human anser and computer answer
  31. computerans=randnum+randnum2;
  32. if(ans==computerans)
  33. {
  34. //if you get one right it keeps track
  35. cor=cor+1;
  36. }
  37. else if(ans!=computerans)
  38. {
  39. //if you get one wrong it keeps track
  40. in=in+1;
  41. }
  42. }
  43. //check if qustion is subraction
  44. else if (oper=2)
  45. {
  46.  
  47. randnum=rand()% 100;
  48. randnum2=rand()% 100;
  49. cout<<randnum<<"-"<<randnum2<<" enter your answer -> ";
  50. cin>>ans;
  51. computerans=randnum-randnum2;
  52. if(ans==computerans)
  53. {
  54. cor=cor+1;
  55. }
  56. else if(ans!=computerans)
  57. {
  58. in=in+1;
  59. }
  60. }
  61. //check if its multipication
  62. else if (oper=3)
  63. {
  64.  
  65. randnum=rand()% 100;
  66. randnum2=rand()% 100;
  67. cout<<randnum<<"X"<<randnum2<<" enter your answer -> ";
  68. cin>>ans;
  69. computerans=randnum*randnum2;
  70. if(ans==computerans)
  71. {
  72. cor=cor+1;
  73. }
  74. else if(ans!=computerans)
  75. {
  76. in=in+1;
  77. }
  78. }
  79. //check if its divison
  80. else if (oper=4)
  81. {
  82.  
  83. randnum=rand()% 100;
  84. randnum2=rand()% 100;
  85. cout<<randnum<<"/"<<randnum2<<" enter your answer -> ";
  86. cin>>ans;
  87. computerans=randnum/randnum2;
  88. if(ans==computerans)
  89. {
  90. cor=cor+1;
  91. }
  92. else if(ans!=computerans)
  93. {
  94. in=in+1;
  95. }
  96. }
  97. }
  98.  
  99. cout<<"\n\n\n\n\nyou have finished you got"<<cor<<" correct and "<<in<<" incorrect";
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement