Advertisement
illpastethat

Bubble Sort

Jun 9th, 2011
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. Create a C++ program that will use a function to perform a bubble sort of an array of records.
  2.  
  3. The program should first prompt the user for values to populate an array of 5 grade records each containing 2 fields (i.e., int Grade, int StudentNumber). The program should then call a function to perform a bubble sort to sort the records in the array by the Grade field, and display the sorted records to the user.
  4.  
  5. Start with the template program.
  6. A sample session:
  7.  
  8. Please enter grades and student numbers for 5 students:
  9.  
  10. Please enter a grade:87
  11.  
  12. Please enter a student number: 10140567
  13.  
  14. Please enter a grade:77
  15.  
  16. Please enter a student number: 10111267
  17.  
  18. Please enter a grade:66
  19.  
  20. Please enter a student number: 10983645
  21.  
  22. Please enter a grade:82
  23.  
  24. Please enter a student number: 11238765
  25.  
  26. Please enter a grade:70
  27.  
  28. Please enter a student number: 10546967
  29.  
  30. Thank you... sorting....
  31.  
  32. The sorted list is:
  33. Grade Student
  34. 66 10983645
  35. 70 10546967
  36. 77 10111267
  37. 82 11238765
  38. 87 10140567
  39.  
  40. What to hand in:
  41.  
  42. A C++ program named a5q2.cpp containing the C++ program.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement