Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Influxdb Database A Comprehensive Guide To Learn Influxdb Database

Authors: Cybellium Ltd ,Kris Hermans

1st Edition

B0CNGGWL7B, 979-8867766450

Students also viewed these Databases questions

Question

6. Conclude with the same strength as in the introduction

Answered: 1 week ago

Question

7. Prepare an effective outline

Answered: 1 week ago