fork download
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. void bubbleSort(int tests[], int n);
  8. int tests[5];
  9.  
  10.  
  11. int main()
  12. {
  13. int sum, avg;
  14.  
  15. cout << "Enter five test scores " ;
  16.  
  17.  
  18.  
  19.  
  20.  
  21. sum = 0;
  22.  
  23. for (int counter = 0; counter <5; counter++)
  24. {
  25. cin >> tests[counter];
  26. sum = sum + tests[counter];
  27.  
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34. avg = sum/5;
  35.  
  36. cout << " The sum of the test scores is " << sum << endl;
  37. cout << "The average of the test scores is " << avg << endl;
  38.  
  39. bubbleSort(tests[5], 5);
  40.  
  41. for (int counter = 0; counter <5; counter++)
  42. {
  43. cout << tests[counter];
  44. }
  45.  
  46. system("pause");
  47. return 0;
  48.  
  49. }
  50.  
  51. void bubbleSort(int tests[], int n) {
  52.  
  53. bool swapped = true;
  54.  
  55. int j = 0;
  56.  
  57. int tmp;
  58.  
  59. while (swapped) {
  60.  
  61. swapped = false;
  62.  
  63. j++;
  64.  
  65. for (int i = 0; i < n - j; i++) {
  66.  
  67. if (tests[i] > tests[i + 1]) {
  68.  
  69. tmp = tests[i];
  70.  
  71. tests[i] = tests[i + 1];
  72.  
  73. tests[i + 1] = tmp;
  74.  
  75. swapped = true;
  76.  
  77. }
  78.  
  79. }
  80.  
  81. }
  82.  
  83. }
  84.  
  85.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:39: error: invalid conversion from ‘int’ to ‘int*’
prog.cpp:39: error:   initializing argument 1 of ‘void bubbleSort(int*, int)’
prog.cpp:46: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result
stdout
Standard output is empty