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

Write a C++ program that prompts the user for 5 numbers. The values shall be sto

ID: 3863361 • Letter: W

Question

Write a C++ program that prompts the user for 5 numbers. The values shall be stored in an array name “numb”. You must have a function named “lo_2_hi” that will accept the array of numbers as an argument and will sort the list of numbers in increasing order. The list of increasing numbers must replace the original list of numbers in “numb” and be returned to the main function where it will be output to the screen. No global variables can be used. all programs ( unless otherwise noted) must prompt the user to rerun the program by typing "yes" or "Yes" . Upon exiting the program, you must “thank the user” for using it. (Programmed in C++)

Explanation / Answer

// sort.cpp : Defines the entry point for the console application.
//

#include<iostream>
#include<conio.h>
#include <string>
#include <algorithm>

using namespace std;

int* lo_2_h(int a[])
{
   int i, temp=0, j;

     
   for (i = 0; i <= 4; i++)
   {
       for (j = 0; j <= 4 - 1; j++)
       {
           if (a[j]>a[j + 1])
           {
               temp = a[j];
               a[j] = a[j + 1];
               a[j + 1] = temp;
           }
       }
   }
   return a;
}

void main()
{
   string str;
   do
   {
       int numb[5];
       cout << "Enter any 5 num in array: ";
       for (int i = 0; i <= 4; i++)
       {
           cin >> numb[i];
       }

       int* a = lo_2_h(numb);
       cout << " Data after sorting: ";
       for (int j = 0; j <= 4; j++)
       {
           cout << a[j] << " ";
       }
       cout << endl;
       cout << "press yes if you want to continue" << endl;
       cin >> str;
       std::transform(str.begin(), str.end(), str.begin(), ::tolower);
   } while (str.compare("yes") == 0);

   cout << "thank u";
  

  
}

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