Advertisement
Guest User

code

a guest
Jun 30th, 2015
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. //programming language "C" ...
  2.  
  3.  
  4. #include <stdio.h>//for all xD
  5. #include <time.h> //for random
  6. #include <string.h> //only 2 be sure
  7. #include <stdlib.h>//for some shit
  8.  
  9.  
  10. int main()
  11. {
  12.  
  13. srand ((unsigned)time(NULL));
  14. int max; //maximalnumber
  15. int maxtasks;//how many tasks
  16. int tasks;//only int to count the tasks
  17. int right = 0;//rightanswers
  18. int wrong = 0;//wronganswers
  19. int d;
  20. printf("How many exercises do you want to have?\n");
  21. scanf("%i",&maxtasks);
  22. printf("Put in the max of your number: ");
  23. scanf("%i",&max);
  24. int a = rand()%max;
  25. int b = rand()%max;
  26. int c = a + b;
  27. printf("%i + %i = ",a,b);
  28. scanf("%i",&d);
  29. if (d == c)
  30. {
  31. printf("right\n");
  32. }
  33. else
  34. {
  35. printf("wrong\n");
  36. }
  37. for (tasks=1;tasks < maxtasks;tasks++)
  38. {
  39. a = rand()%max;
  40. b = rand()%max;
  41. c = a + b;
  42. printf("%i + %i = ",a,b);
  43. scanf("%i",&d);
  44. if (d == c)
  45. {
  46. printf("right\n");
  47. right += 1;
  48. }
  49. else
  50. {
  51. printf("wrong\n");
  52. wrong += 1;
  53. }
  54. }
  55. double percentright = 100 / maxtasks * right;
  56. printf("You have %lf percent right\n",percentright);
  57. return 0;
  58. }
  59. a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement