Here is the documented code to solve this assignment:
chegg.cpp:
#include <iostream>
#define SIZE 10
void show(const int (&A)[SIZE],
const int N) {
for(int i = 0; i < N; ++i) {
std::cout << A[i] << ", ";
}
std::cout << "\b\b " << std::endl;
}
int Find_Location_To_Insert(const int (&A)[SIZE],
const int N,
int &K,
const int ITEM) {
int LB = 0, UB = N - 1;
for(K = LB; K <= UB; ++K) {
if(A[K] > ITEM) {
// insert at front or in middle
return K;
}
}
// insert at the end of array
return K;
}
void INSERT(int (&A)[SIZE],
int &N,
int K,
const int ITEM) {
// initialize counter
int J = N - 1;
while(J >= K) {
// move the Jth element downward
A[J + 1] = A[J];
// decrease counter
J = J - 1;
}
// insert element
A[K] = ITEM;
// reset N
N = N + 1;
}
int main() {
int A[SIZE];
int N = 0;
int ITEM;
int K;
while(true) {
show(A, N);
// overflow check
if(N == SIZE) {
std::cout << "Overflow, Array is Full." << std::endl;
break;
}
Step by stepSolved in 3 steps with 1 images
- (golang) products := [5] string {"bread", "milk", "eggs", "butter", "sugar"} Declare an array of 5 float64 named "prices" pre-populate the array with reasonable prices for each item; prices should "parallel" the products (i.e., prices[0] is the price for products[0])arrow_forwardC Programmingarrow_forward(Horizontal and Vertical Stacking) Create the two-dimensional arrays array1 = np.array([[0, 1], [2, 3]]) array2 = np.array([[4, 5], [6, 7]]) a) Use vertical stacking to create the 4-by-2 array named array3 with array1 stacked on top of array2. b) Use horizontal stacking to create the 2-by-4 array named array4 with array2 to the right of array1. c) Use vertical stacking with two copies of array4 to create a 4-by-4 array5. d) Use horizontal stacking with two copies of array3 to create a 4-by-4 array6. Please use Python and keep it simplearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education