Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that asks the user to enter 1000 integers to be stored in an arr

ID: 3835286 • Letter: W

Question

Write a program that asks the user to enter 1000 integers to be stored in an array called "numbers". Since the same integer might occur (exist) in the array multiple times, your program needs to fill a second array, called "Isolate" that contains all the integers from the first array but NOT REPAPTED (every integer will exist only once). Finally, your program will print the integers of the second array sorted by occurrence (occurrence is; the number of times the element is repeated in the first array). You can use any sorting algorithm you want. (You must use at least one function in your program)

Explanation / Answer

Hi,

You have not mentioned the programming language in which we need to implement this requirement. I have written the code in C++.

C++ Code-

#include <iostream>
using namespace std;

int main(){
   int values, numbers[1000] = {};
   cout << "How many input values[max: 1000]? ";
   cin >> values;
   cout << "Enter " << values << " numbers. ";
   for (int i = 0; i < values; i++){
       cin >> numbers[i];
   }

   int biggestNum = numbers[0], temp;
   for (int i = 0; i < values; i++){
       temp = numbers[i];
       if (temp > biggestNum){
           biggestNum = temp;
       }
      
   }
   cout << "Largest Number is : " << biggestNum << endl;
int size = biggestNum + 1;
int isolate[size];

for(int i = 0; i < size ; i++)
isolate[i] = 0;

for(int i = 0; i < size; i++)
++isolate[numbers[i]];

//now print number - isolate

for(int i = 0; i < size+ 1; i++)
if(isolate[i] == 0)
;
else
cout<<i<<" ------- "<<isolate[i]<<endl;
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote