Question: [c++ programming question] Could you help me one of my methods? I have to sort my array by using bubble sort and output my values.

[c++ programming question]

Could you help me one of my methods? I have to sort my array by using "bubble sort" and output my values.

Here is my code;

#include  #include  #include  #include  // To get rid of error of rand not declared in this scope ??? using namespace std; class Random { private: double num; public: Random() {} void allValues(int array[]) { cout << "Show all values" << endl; for(int i =0; i < 1000; i++) { cout << array[i] << endl; } } void sumValues(int array[]) { cout << "Output the sum of all values" << endl; int sum = 0; for(int i = 0; i < 1000; i++) { sum += array[i]; } cout << sum < highValue) { highValue = array[i]; } } cout << highValue <> searchValue; flag = 0; for(int i = 0; i < 1000; i ++) { if(array[i] == searchValue) { cout << searchValue << "is located at" << i << endl; flag = 1; } } if(!flag) { cout << searchValue << "is not exsited in array" << endl; } } }; int main() { int ranNum; //random number const int arraySize = 1000; // Array size int array[arraySize]; ofstream outfile; outfile.open("randomfile"); srand(time(0)); cout << "Writing data to file..."<> array[i]; } file.close(); cout << "===========================================================" << " "; for (int j=0;j <4;j++) { cout << array[j] << " "; } Random rd; // random rd is not working wtf? rd.allValues(array); /** * Here while passing the array as parameter, we just need to send * the name of the array without its size */ rd.sumValues(array); rd.oddValue(array); rd.evenValue(array); rd.middleValue(array); rd.firstValue(array); rd.lastValue(array); rd.highestValue(array); rd.lowestValue(array); rd.linearSearch(array); return 0; } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!