Guest User

My solutions to the Ultra Easy questions

a guest
Sep 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. Ultra Easy:
  2.  
  3. 1. cout << "gentjew";
  4.  
  5. 2. For (int i = 700; i > 200; i = i - 13)
  6. cout << i;
  7.  
  8. 3. cout << X[2-1]
  9.  
  10. 4a. int sum;
  11. {for (int i = 0; i < 1001; i = i + 1)
  12. sum = sum + i};
  13. cout << sum;
  14. 4b. int sum;
  15. {for (int i = x; i < y; i = i + 1)
  16. sum = sum + i}
  17. cout << sum;
  18.  
  19. 5. string i;
  20. cin << i;
  21. {if i == "Jack"
  22. cout << "Hi, Jack!" << endl
  23. else
  24. cout << "Hello, " << i << endl}
  25.  
  26. 6a. for (int i = 0; i < 101; i = i + 1)
  27. {if i % 2 == 1
  28. cout << i << "is an odd number" << endl;
  29. else
  30. cout << i << "is an even number"; << endl}
  31.  
  32. 6b. cout << "The following numbers are all even numbers" << endl;
  33. {for ( int i = 0; i < 101; i = i + 2)
  34. cout << i << endl}
  35.  
  36. cout << "The following numbers are all odd numbers" << endl;
  37. {for ( int i = 1; i < 101; i = i + 2)
  38. cout << i << endl}
  39.  
  40. 6c. already done
  41.  
  42. 7. {for (int i = 0; i < 13; i = i + 1)
  43. cout << endl
  44. for int j = 0; j < 13; j = j + 1
  45. cout << i * j << " ";}
  46.  
  47. 8. can't solve it without googling, which would be cheating, but basically you use strtok with a space as a delimiter in a loop and null to end it
  48.  
  49. 9. int i,j,k
  50. i = rand()
  51. j = rand()
  52. k = rand()
  53.  
  54. int average
  55.  
  56. average = (i + j + k)/3
  57. cout << average
  58.  
  59. {if (i > j && i > k)
  60. cout << i << "is the biggest number"}
  61.  
  62. {if (j > i && j >k)
  63. cout << j << "is the biggest number"}
  64.  
  65. {if (k > i && k > j)
  66. cout << k << "is the biggest number"}}
  67.  
  68. repeat with reversed <> for smallest number
  69.  
  70. 10. int grade
  71. string project
  72. cin << grade
  73. cin << project
  74.  
  75. {if grade < 50
  76. {if project == Y
  77. cout << "You scored C"
  78. else
  79. cout << "You scored F"}}
  80.  
  81. {if grade > 50 && grade < 69
  82. {if project = Y
  83. cout << "You scored B"
  84. else
  85. cout << "You scored C"}}
  86.  
  87. etc you get the idea, just remember to cap the grades so if you get 100 you don't output all grades above 50
  88.  
  89. 11. int X[99]
  90. for (int i = 0; i < 100; i = i + 1)
  91. X[i] = rand()%10000
  92.  
  93. int yournumber
  94. cin << yournumber
  95. for (int i = 0; i <100; i = i + 1)
  96. if (yournumber == X[i])
  97. cout << "your number was in the list!"
  98. else
  99. cout << "your number wasn't in the list.";
  100.  
  101. 12. cout << Welcome to higher or lower!
  102. int Player, oldnumber, newnumber, computerguess;
  103. string HL;
  104.  
  105. while (J == 1)
  106. oldnumber = rand()%100
  107. cout << "Do you think the number will be higher, or lower next time than" << oldnumber << endl;
  108. newnumber = rand()%100
  109. cin << HL
  110. cout << endl << The next number is << newnumber << endl;
  111.  
  112. {if (HL == Higher || HL == higher)
  113. {if newnumber > oldnumber
  114. cout << "You win! Continue guessing!" << endl
  115. else
  116. cout << "You lose! The computer's turn now!" << endl; J = 0}}
  117.  
  118. {if (HL == Lower || HL == lower)
  119. {if newnumber < oldnumber
  120. cout << "You win! Continue guessing!" << endl
  121. else
  122. cout << "You lose! The computer's turn now!" << endl; J = 0}}
  123.  
  124. While (J == 0)
  125. oldnumber = rand()%100
  126. cout << "The computer is guessing whether the number will be higher or lower than" << oldnumber << endl;
  127. newnumber = rand()%100
  128. computerguess = rand()%2
  129.  
  130. cout << "The next number is" << newnumber << endl;
  131.  
  132. {if (computerguess == 0)
  133. HL = Higher
  134. else
  135. HL = Lower}
  136.  
  137. {if (HL == Higher || HL == higher)
  138. Cout << "The computer guessed Higher and he was "
  139. {if newnumber > oldnumber
  140. cout << "right! He gets another go." << endl
  141. else
  142. cout << "wrong! It's your turn now!" << endl; J = 1}}
  143.  
  144. {if (HL == Lower || HL == Lower)
  145. Cout << "The computer guessed Lower and he was "
  146. {if newnumber < oldnumber
  147. cout << "right! He gets another go." << endl
  148. else
  149. cout << "wrong! It's your turn now!" << endl; J = 1}}
  150.  
  151.  
  152.  
  153.  
  154. follow me @realdonaldtrump or @mido9_2
Add Comment
Please, Sign In to add comment