ChorongBias

main

Jan 17th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #define SIZE 12
  3. extern int Pedestrian[];
  4. extern int MotorCyclist[];
  5. extern int MotorCar[];
  6. extern int LightTruck[];
  7. extern int Truck[];
  8. void showMenu(void)
  9. {
  10. printf("Please choose one of the following options\n");
  11. printf("A: Total number of injuries of a selected road user.\nB: Difference between Motor Cyclists injuries and combined injuries of Motor Car, Light truck and Truck.\nC: Percentage of road users' injuries for a selected month.\nD: Difference of road users' injuries between consecutive months for a selected road user type.\nE: Lowest monthly total number of injuries from Jan to Dec.\nF: Highest to lowest number of injuries for a selected road user type.\nQ: Quit the programme\n\n");
  12. }
  13. void function1(void)
  14. {
  15. int j, total, choice;
  16. total = 0;
  17. j = 0;
  18. {
  19. printf("Select a Road User\n");
  20. printf("1)Pedestrian\n2)Motor Cyclists\n3)Motor Car\n4)Light Truck\n5)Truck\n");
  21. scanf_s(" %d", &choice);
  22. if (choice == 1)
  23. {
  24. for (j = 0; j < 12; j++)
  25. total += Pedestrian[j];
  26. printf("The total number of injuries for Pedestrian is %d\n\n", total);
  27. }
  28. else if (choice == 2)
  29. {
  30. for (j = 0; j < 12; j++)
  31. total += MotorCyclist[j];
  32. printf("The total number of injuries for Motor Cyclists is %d\n\n", total);
  33.  
  34. }
  35. else if (choice == 3)
  36. {
  37. for (j = 0; j < 12; j++)
  38. total += MotorCar[j];
  39. printf("The total number of injuries for Motor Car is %d\n\n", total);
  40. }
  41. else if (choice == 4)
  42. {
  43. for (j = 0; j < 12; j++)
  44. total += LightTruck[j];
  45. printf("The total number of injuries for Light Truck is %d\n\n", total);
  46. }
  47. else if (choice == 5)
  48. {
  49. for (j = 0; j < 12; j++)
  50. total += Truck[j];
  51. printf("The total number of injuries for Truck is %d\n\n", total);
  52. }
  53. else
  54. {
  55. printf("Invalid, try again\n\n");
  56. }
  57.  
  58.  
  59. }
  60. }
  61. void function2(void)
  62. {
  63. int j, difference;
  64. j = 0;
  65. difference = 0;
  66. {
  67. for (j = 0; j < 12; j++)
  68. difference += MotorCyclist[j] - (MotorCar[j] + LightTruck[j] + Truck[j]);
  69. printf("The difference between MotorCyclists injuries and combined injuries of Motor Car, Light Truck and Truck is %d\n\n", difference);
  70. }
  71.  
  72.  
  73. }
  74. void function3(void)
  75. {
  76. int j, choice, total;
  77. float percentage;
  78. total = 0;
  79. j = 0;
  80. percentage = 0.0;
  81.  
  82. {
  83. printf("Select a month\n");
  84. printf("1)Jan\n2)Feb\n3)Mar\n4)Apr\n5)May\n6)Jun\n7)Jul\n8)Aug\n9)Sep\n10)Oct\n11)Nov\n12)Dec\n");
  85. scanf_s(" %d", &choice);
  86. if (choice == 1)
  87. {
  88. for (j = 0; j < 12; j++)
  89. total = total + Pedestrian[j] + MotorCyclist[j] + MotorCar[j] + LightTruck[j] + Truck[j];
  90. percentage = (percentage + Pedestrian[0] + MotorCyclist[0] + MotorCar[0] + LightTruck[0] + Truck[0]) / total * 100;
  91. printf("The percentage of road users' injuries in January is %.2f%%\n", percentage);
  92. }
  93. else if (choice == 2)
  94. {
  95. for (j = 0; j < 12; j++)
  96. total = total + Pedestrian[j] + MotorCyclist[j] + MotorCar[j] + LightTruck[j] + Truck[j];
  97. percentage = (percentage + Pedestrian[1] + MotorCyclist[1] + MotorCar[1] + LightTruck[1] + Truck[1]) / total * 100;
  98. printf("The percentage of road users' injuries in February is %.2f%%\n", percentage);
  99. }
  100. else if (choice == 3)
  101. {
  102. for (j = 0; j < 12; j++)
  103. total = total + Pedestrian[j] + MotorCyclist[j] + MotorCar[j] + LightTruck[j] + Truck[j];
  104. percentage = (percentage + Pedestrian[2] + MotorCyclist[2] + MotorCar[2] + LightTruck[2] + Truck[2]) / total * 100;
  105. printf("The percentage of road users' injuries in March is %.2f%%\n", percentage);
  106. }
  107. else if (choice == 4)
  108. {
  109. for (j = 0; j < 12; j++)
  110. total = total + Pedestrian[j] + MotorCyclist[j] + MotorCar[j] + LightTruck[j] + Truck[j];
  111. percentage = (percentage + Pedestrian[3] + MotorCyclist[3] + MotorCar[3] + LightTruck[3] + Truck[3]) / total * 100;
  112. printf("The percentage of road users' injuries in April is %.2f%%\n", percentage);
  113. }
  114. else if (choice == 5)
  115. {
  116. for (j = 0; j < 12; j++)
  117. total = total + Pedestrian[j] + MotorCyclist[j] + MotorCar[j] + LightTruck[j] + Truck[j];
  118. percentage = (percentage + Pedestrian[4] + MotorCyclist[4] + MotorCar[4] + LightTruck[4] + Truck[4]) / total * 100;
  119. printf("The percentage of road users' injuries in May is %.2f%%\n", percentage);
  120. }
  121. else if (choice == 6)
  122. {
  123. for (j = 0; j < 12; j++)
  124. total = total + Pedestrian[j] + MotorCyclist[j] + MotorCar[j] + LightTruck[j] + Truck[j];
  125. percentage = (percentage + Pedestrian[5] + MotorCyclist[5] + MotorCar[5] + LightTruck[5] + Truck[5]) / total * 100;
  126. printf("The percentage of road users' injuries in June is %.2f%%\n", percentage);
  127. }
  128. else if (choice == 7)
  129. {
  130. for (j = 0; j < 12; j++)
  131. total = total + Pedestrian[j] + MotorCyclist[j] + MotorCar[j] + LightTruck[j] + Truck[j];
  132. percentage = (percentage + Pedestrian[6] + MotorCyclist[6] + MotorCar[6] + LightTruck[6] + Truck[6]) / total * 100;
  133. printf("The percentage of road users' injuries in July is %.2f%%\n", percentage);
  134. }
  135. else if (choice == 8)
  136. {
  137. for (j = 0; j < 12; j++)
  138. total = total + Pedestrian[j] + MotorCyclist[j] + MotorCar[j] + LightTruck[j] + Truck[j];
  139. percentage = (percentage + Pedestrian[7] + MotorCyclist[7] + MotorCar[7] + LightTruck[7] + Truck[7]) / total * 100;
  140. printf("The percentage of road users' injuries in August is %.2f%%\n", percentage);
  141. }
  142. else if (choice == 9)
  143. {
  144. for (j = 0; j < 12; j++)
  145. total = total + Pedestrian[j] + MotorCyclist[j] + MotorCar[j] + LightTruck[j] + Truck[j];
  146. percentage = (percentage + Pedestrian[8] + MotorCyclist[8] + MotorCar[8] + LightTruck[8] + Truck[8]) / total * 100;
  147. printf("The percentage of road users' injuries in September is %.2f%%\n", percentage);
  148. }
  149. else if (choice == 10)
  150. {
  151. for (j = 0; j < 12; j++)
  152. total = total + Pedestrian[j] + MotorCyclist[j] + MotorCar[j] + LightTruck[j] + Truck[j];
  153. percentage = (percentage + Pedestrian[9] + MotorCyclist[9] + MotorCar[9] + LightTruck[9] + Truck[9]) / total * 100;
  154. printf("The percentage of road users' injuries in October is %.2f%%\n", percentage);
  155. }
  156. else if (choice == 11)
  157. {
  158. for (j = 0; j < 12; j++)
  159. total = total + Pedestrian[j] + MotorCyclist[j] + MotorCar[j] + LightTruck[j] + Truck[j];
  160. percentage = (percentage + Pedestrian[10] + MotorCyclist[10] + MotorCar[10] + LightTruck[10] + Truck[10]) / total * 100;
  161. printf("The percentage of road users' injuries in November is %.2f%%\n", percentage);
  162. }
  163. else if (choice == 12)
  164. {
  165. for (j = 0; j < 12; j++)
  166. total = total + Pedestrian[j] + MotorCyclist[j] + MotorCar[j] + LightTruck[j] + Truck[j];
  167. percentage = (percentage + Pedestrian[11] + MotorCyclist[11] + MotorCar[11] + LightTruck[11] + Truck[11]) / total * 100;
  168. printf("The percentage of road users' injuries in December is %.2f%%\n", percentage);
  169. }
  170. else
  171. {
  172. printf("Invalid, try again\n\n");
  173. }
  174. }
  175. }
  176.  
  177. void function4(void)
  178. {
  179. int difference[11];
  180. int choice;
  181. printf("Please select a Road User\n");
  182. printf("1)Pedestrian\n2)Motor Cyclists\n3)Motor Car\n4)Light Truck\n5)Truck\n\n");
  183. scanf_s("%d", &choice);
  184. if (choice == 1)
  185. {
  186. difference[0] = Pedestrian[0] - Pedestrian[1];
  187. difference[1] = Pedestrian[2] - Pedestrian[1];
  188. difference[2] = Pedestrian[2] - Pedestrian[3];
  189. difference[3] = Pedestrian[4] - Pedestrian[3];
  190. difference[4] = Pedestrian[4] - Pedestrian[5];
  191. difference[5] = Pedestrian[6] - Pedestrian[5];
  192. difference[6] = Pedestrian[7] - Pedestrian[6];
  193. difference[7] = Pedestrian[7] - Pedestrian[8];
  194. difference[8] = Pedestrian[9] - Pedestrian[8];
  195. difference[9] = Pedestrian[9] - Pedestrian[10];
  196. difference[10] = Pedestrian[11] - Pedestrian[10];
  197. printf("The difference between January and February is %d\n", difference[0]);
  198. printf("The difference between February and March is %d\n", difference[1]);
  199. printf("The difference between March and April is %d\n", difference[2]);
  200. printf("The difference between April and May is %d\n", difference[3]);
  201. printf("The difference between May and June is %d\n", difference[4]);
  202. printf("The difference between June and July is %d\n", difference[5]);
  203. printf("The difference between July and August is %d\n", difference[6]);
  204. printf("The difference between August and September is %d\n", difference[7]);
  205. printf("The difference between September and October is %d\n", difference[8]);
  206. printf("The difference between October and November is %d\n", difference[9]);
  207. printf("The difference between November and December is %d\n", difference[10]);
  208.  
  209. }
  210. else if (choice == 2)
  211. {
  212. difference[0] = MotorCyclist[1] - MotorCyclist[0];
  213. difference[1] = MotorCyclist[2] - MotorCyclist[1];
  214. difference[2] = MotorCyclist[2] - MotorCyclist[3];
  215. difference[3] = MotorCyclist[3] - MotorCyclist[4];
  216. difference[4] = MotorCyclist[4] - MotorCyclist[5];
  217. difference[5] = MotorCyclist[6] - MotorCyclist[5];
  218. difference[6] = MotorCyclist[7] - MotorCyclist[6];
  219. difference[7] = MotorCyclist[7] - MotorCyclist[8];
  220. difference[8] = MotorCyclist[9] - MotorCyclist[8];
  221. difference[9] = MotorCyclist[10] - MotorCyclist[9];
  222. difference[10] = MotorCyclist[10] - MotorCyclist[11];
  223. printf("The difference between January and February is %d\n", difference[0]);
  224. printf("The difference between February and March is %d\n", difference[1]);
  225. printf("The difference between March and April is %d\n", difference[2]);
  226. printf("The difference between April and May is %d\n", difference[3]);
  227. printf("The difference between May and June is %d\n", difference[4]);
  228. printf("The difference between June and July is %d\n", difference[5]);
  229. printf("The difference between July and August is %d\n", difference[6]);
  230. printf("The difference between August and September is %d\n", difference[7]);
  231. printf("The difference between September and October is %d\n", difference[8]);
  232. printf("The difference between October and November is %d\n", difference[9]);
  233. printf("The difference between November and December is %d\n", difference[10]);
  234. }
  235. else if (choice == 3)
  236. {
  237. difference[0] = MotorCar[0] - MotorCar[1];
  238. difference[1] = MotorCar[1] - MotorCar[2];
  239. difference[2] = MotorCar[3] - MotorCar[2];
  240. difference[3] = MotorCar[4] - MotorCar[3];
  241. difference[4] = MotorCar[4] - MotorCar[5];
  242. difference[5] = MotorCar[6] - MotorCar[5];
  243. difference[6] = MotorCar[7] - MotorCar[6];
  244. difference[7] = MotorCar[7] - MotorCar[8];
  245. difference[8] = MotorCar[9] - MotorCar[8];
  246. difference[9] = MotorCar[9] - MotorCar[10];
  247. difference[10] = MotorCar[10] - MotorCar[11];
  248. printf("The difference between January and February is %d\n", difference[0]);
  249. printf("The difference between February and March is %d\n", difference[1]);
  250. printf("The difference between March and April is %d\n", difference[2]);
  251. printf("The difference between April and May is %d\n", difference[3]);
  252. printf("The difference between May and June is %d\n", difference[4]);
  253. printf("The difference between June and July is %d\n", difference[5]);
  254. printf("The difference between July and August is %d\n", difference[6]);
  255. printf("The difference between August and September is %d\n", difference[7]);
  256. printf("The difference between September and October is %d\n", difference[8]);
  257. printf("The difference between October and November is %d\n", difference[9]);
  258. printf("The difference between November and December is %d\n", difference[10]);
  259. }
  260. else if (choice == 4)
  261. {
  262. difference[0] = LightTruck[1] - LightTruck[0];
  263. difference[1] = LightTruck[1] - LightTruck[2];
  264. difference[2] = LightTruck[2] - LightTruck[3];
  265. difference[3] = LightTruck[4] - LightTruck[3];
  266. difference[4] = LightTruck[4] - LightTruck[5];
  267. difference[5] = LightTruck[5] - LightTruck[6];
  268. difference[6] = LightTruck[7] - LightTruck[6];
  269. difference[7] = LightTruck[7] - LightTruck[8];
  270. difference[8] = LightTruck[9] - LightTruck[8];
  271. difference[9] = LightTruck[9] - LightTruck[10];
  272. difference[10] = LightTruck[10] - LightTruck[11];
  273. printf("The difference between January and February is %d\n", difference[0]);
  274. printf("The difference between February and March is %d\n", difference[1]);
  275. printf("The difference between March and April is %d\n", difference[2]);
  276. printf("The difference between April and May is %d\n", difference[3]);
  277. printf("The difference between May and June is %d\n", difference[4]);
  278. printf("The difference between June and July is %d\n", difference[5]);
  279. printf("The difference between July and August is %d\n", difference[6]);
  280. printf("The difference between August and September is %d\n", difference[7]);
  281. printf("The difference between September and October is %d\n", difference[8]);
  282. printf("The difference between October and November is %d\n", difference[9]);
  283. printf("The difference between November and December is %d\n", difference[10]);
  284. }
  285. else if (choice == 5)
  286. {
  287. difference[0] = Truck[0] - Truck[1];
  288. difference[1] = Truck[1] - Truck[2];
  289. difference[2] = Truck[3] - Truck[2];
  290. difference[3] = Truck[3] - Truck[4];
  291. difference[4] = Truck[5] - Truck[4];
  292. difference[5] = Truck[5] - Truck[6];
  293. difference[6] = Truck[7] - Truck[6];
  294. difference[7] = Truck[7] - Truck[8];
  295. difference[8] = Truck[8] - Truck[9];
  296. difference[9] = Truck[10] - Truck[9];
  297. difference[10] = Truck[10] - Truck[11];
  298. printf("The difference between January and February is %d\n", difference[0]);
  299. printf("The difference between February and March is %d\n", difference[1]);
  300. printf("The difference between March and April is %d\n", difference[2]);
  301. printf("The difference between April and May is %d\n", difference[3]);
  302. printf("The difference between May and June is %d\n", difference[4]);
  303. printf("The difference between June and July is %d\n", difference[5]);
  304. printf("The difference between July and August is %d\n", difference[6]);
  305. printf("The difference between August and September is %d\n", difference[7]);
  306. printf("The difference between September and October is %d\n", difference[8]);
  307. printf("The difference between October and November is %d\n", difference[9]);
  308. printf("The difference between November and December is %d\n", difference[10]);
  309. }
  310. else
  311. {
  312. printf("Invalid,Please try again\n\n");
  313. }
  314.  
  315. }
  316. void function5(void)
  317. {
  318. int total[12];
  319. total[0] = Pedestrian[0] + MotorCyclist[0] + MotorCar[0] + LightTruck[0] + Truck[0];
  320. total[1] = Pedestrian[1] + MotorCyclist[1] + MotorCar[1] + LightTruck[1] + Truck[1];
  321. total[2] = Pedestrian[2] + MotorCyclist[2] + MotorCar[2] + LightTruck[2] + Truck[2];
  322. total[3] = Pedestrian[3] + MotorCyclist[3] + MotorCar[3] + LightTruck[3] + Truck[3];
  323. total[4] = Pedestrian[4] + MotorCyclist[4] + MotorCar[4] + LightTruck[4] + Truck[4];
  324. total[5] = Pedestrian[5] + MotorCyclist[5] + MotorCar[5] + LightTruck[5] + Truck[5];
  325. total[6] = Pedestrian[6] + MotorCyclist[6] + MotorCar[6] + LightTruck[6] + Truck[6];
  326. total[7] = Pedestrian[7] + MotorCyclist[7] + MotorCar[7] + LightTruck[7] + Truck[7];
  327. total[8] = Pedestrian[8] + MotorCyclist[8] + MotorCar[8] + LightTruck[8] + Truck[8];
  328. total[9] = Pedestrian[9] + MotorCyclist[9] + MotorCar[9] + LightTruck[9] + Truck[9];
  329. total[10] = Pedestrian[10] + MotorCyclist[10] + MotorCar[10] + LightTruck[10] + Truck[10];
  330. total[11] = Pedestrian[11] + MotorCyclist[11] + MotorCar[11] + LightTruck[11] + Truck[11];
  331.  
  332. if (total[0] < total[1] && total[0] < total[2] && total[0] < total[3] && total[0] < total[4] && total[0] < total[5] && total[0] < total[6] && total[0] < total[7] && total[0] < total[8] && total[0] < total[9] && total[0] < total[10] && total[0] < total[11])
  333. {
  334. printf("The lowest monthly total number of injuries is January %d\n", total[0]);
  335. }
  336. else if (total[1] < total[0] && total[1] < total[2] && total[1] < total[3] && total[1] < total[4] && total[1] < total[5] && total[1] < total[6] && total[1] < total[7] && total[1] < total[8] && total[1] < total[9] && total[1] < total[10] && total[1] < total[11])
  337. {
  338. printf("The lowest monthly total number of injuries is February %d\n", total[1]);
  339. }
  340. else if (total[2] < total[0] && total[2] < total[1] && total[2] < total[3] && total[2] < total[4] && total[2] < total[5] && total[2] < total[6] && total[2] < total[7] && total[2] < total[8] && total[2] < total[9] && total[2] < total[10] && total[2] < total[11])
  341. {
  342. printf("The lowest monthly total number of injuries is March %d\n", total[2]);
  343. }
  344. else if (total[3] < total[0] && total[3] < total[1] && total[3] < total[2] && total[3] < total[4] && total[3] < total[5] && total[3] < total[6] && total[3] < total[7] && total[3] < total[8] && total[3] < total[9] && total[3] < total[10] && total[3] < total[11])
  345. {
  346. printf("The lowest monthly total number of injuries is April %d\n", total[3]);
  347. }
  348. else if (total[4] < total[0] && total[4] < total[1] && total[4] < total[2] && total[4] < total[3] && total[4] < total[5] && total[4] < total[6] && total[4] < total[7] && total[4] < total[8] && total[4] < total[9] && total[4] < total[10] && total[4] < total[11])
  349. {
  350. printf("The lowest monthly total number of injuries is May %d\n", total[4]);
  351. }
  352. else if (total[5] < total[0] && total[5] < total[1] && total[5] < total[2] && total[5] < total[3] && total[5] < total[4] && total[5] < total[6] && total[5] < total[7] && total[5] < total[8] && total[5] < total[9] && total[5] < total[10] && total[5] < total[11])
  353. {
  354. printf("The lowest monthly total number of injuries is June %d\n", total[5]);
  355. }
  356. else if (total[6] < total[0] && total[6] < total[1] && total[6] < total[2] && total[6] < total[3] && total[6] < total[4] && total[6] < total[5] && total[6] < total[7] && total[6] < total[8] && total[6] < total[9] && total[6] < total[10] && total[6] < total[11])
  357. {
  358. printf("The lowest monthly total number of injuries is July %d\n", total[6]);
  359. }
  360. else if (total[7] < total[0] && total[7] < total[1] && total[7] < total[2] && total[7] < total[3] && total[7] < total[4] && total[7] < total[5] && total[7] < total[6] && total[7] < total[8] && total[7] < total[9] && total[7] < total[10] && total[7] < total[11])
  361. {
  362. printf("The lowest monthly total number of injuries is August %d\n", total[7]);
  363. }
  364. else if (total[8] < total[0] && total[8] < total[1] && total[8] < total[2] && total[8] < total[3] && total[8] < total[4] && total[8] < total[5] && total[8] < total[6] && total[8] < total[7] && total[8] < total[9] && total[8] < total[10] && total[8] < total[11])
  365. {
  366. printf("The lowest monthly total number of injuries is September %d\n", total[8]);
  367. }
  368. else if (total[9] < total[0] && total[9] < total[1] && total[9] < total[2] && total[9] < total[3] && total[9] < total[4] && total[9] < total[5] && total[9] < total[6] && total[9] < total[7] && total[9] < total[8] && total[9] < total[10] && total[9] < total[11])
  369. {
  370. printf("The lowest monthly total number of injuries is October %d\n", total[9]);
  371. }
  372. else if (total[10] < total[0] && total[10] < total[1] && total[10] < total[2] && total[10] < total[3] && total[10] < total[4] && total[10] < total[5] && total[10] < total[6] && total[10] < total[7] && total[10] < total[8] && total[10] < total[9] && total[10] < total[11])
  373. {
  374. printf("The lowest monthly total number of injuries is November %d\n", total[10]);
  375. }
  376. else if (total[11] < total[0] && total[11] < total[1] && total[11] < total[2] && total[11] < total[3] && total[11] < total[4] && total[11] < total[5] && total[11] < total[6] && total[11] < total[7] && total[11] < total[8] && total[11] < total[9] && total[11] < total[10])
  377. {
  378. printf("The lowest monthly total number of injuries is December %d\n", total[11]);
  379. }
  380. else
  381. {
  382. printf("Invalid option!, Please try again\n");
  383. }
  384. }
  385. void function6(void)
  386. {
  387. int z, choice, j, temp;
  388. printf("Select a Road User\n");
  389. printf("1)Pedestrian\n2)Motor Cyclists\n3)Motor Car\n4)Light Truck\n5)Truck\n");
  390. scanf_s(" %d", &choice);
  391. if (choice == 1)
  392. {
  393. for (z = 0; z < 12; z++)
  394. {
  395. for (j = 0; j < 12; j++)
  396. {
  397. if (Pedestrian[j] < Pedestrian[j + 1])
  398. {
  399. temp = Pedestrian[j];
  400. Pedestrian[j] = Pedestrian[j + 1];
  401. Pedestrian[j + 1] = temp;
  402. }
  403. }
  404. }
  405.  
  406.  
  407. printf("The sorted array for Pedestrian in descending order is \n");
  408. for (z = 0; z < 12; z++)
  409. {
  410. printf("%d\n", Pedestrian[z]);
  411. }
  412. }
  413. else if (choice == 2)
  414. {
  415.  
  416. for (z = 0; z < 12; z++)
  417. {
  418. for (j = 0; j < 12; j++)
  419. {
  420. if (MotorCyclist[j] < MotorCyclist[j + 1])
  421. {
  422. temp = MotorCyclist[j];
  423. MotorCyclist[j] = MotorCyclist[j + 1];
  424. MotorCyclist[j + 1] = temp;
  425. }
  426. }
  427. }
  428. printf("The sorted array for Motor Cyclist in descending order is \n");
  429. for (z = 0; z < 12; z++)
  430. {
  431. printf("%d\n", MotorCyclist[z]);
  432. }
  433.  
  434.  
  435. }
  436. else if (choice == 3)
  437. {
  438. for (z = 0; z < 12; z++)
  439. {
  440. for (j = 0; j < 12; j++)
  441. {
  442. if (MotorCar[j] < MotorCar[j + 1])
  443. {
  444. temp = MotorCar[j];
  445. MotorCar[j] = MotorCar[j + 1];
  446. MotorCar[j + 1] = temp;
  447.  
  448. }
  449. }
  450. }
  451. printf("The sorted array for Motor Car in descending order is \n");
  452. for (z = 0; z < 12; z++)
  453. {
  454. printf("%d\n", MotorCar[z]);
  455. }
  456. }
  457. else if (choice == 4)
  458. {
  459. for (z = 0; z < 12; z++)
  460. {
  461. for (j = 0; j < 12; j++)
  462. {
  463. if (LightTruck[j] < LightTruck[j + 1])
  464. {
  465. temp = LightTruck[j];
  466. LightTruck[j] = LightTruck[j + 1];
  467. LightTruck[j + 1] = temp;
  468. }
  469. }
  470. }
  471. printf("The sorted array for Light Truck in descending order is \n");
  472. for (z = 0; z < 12; z++)
  473. {
  474. printf("%d\n", LightTruck[z]);
  475. }
  476. }
  477. else if (choice == 5)
  478. {
  479. for (z = 0; z < 12; z++)
  480. {
  481. for (j = 0; j < 12; j++)
  482. {
  483. if (Truck[j] < Truck[j + 1])
  484. {
  485. temp = Truck[j];
  486. Truck[j] = Truck[j + 1];
  487. Truck[j + 1] = temp;
  488.  
  489. }
  490. }
  491. }
  492. printf("The sorted array for Truck in descending order is \n");
  493. for (z = 0; z < 12; z++)
  494. {
  495. printf("%d\n", Truck[z]);
  496. }
  497. }
  498. else
  499. {
  500. printf("Invalid! Please try again\n");
  501. }
  502. }
Advertisement
Add Comment
Please, Sign In to add comment