Using C++
Insert elements into a partially filled array.
a) Create a partially filled array of CAPACITY 100.
b) Initialize the array with values 10,20,30,40,50,60,70,80,90,100
c) Create a print function for the array.
d) Create an insert function which inserts an integer into the array in sorted position.
e) Insert the numbers 5, 150 and 55.
f) Print the array before and after each insertion.
Output Example
10 20 30 40 50 60 70 80 90 100
5 10 20 30 40 50 60 70 80 90 100
5 10 20 30 40 50 60 70 80 90 100 150
5 10 20 30 40 50 55 60 70 80 90 100 150
If you have any doubts, please give me comment...
#include<iostream>
using namespace std;
#define CAPACITY 100
void print_array(int arr[], int n);
void insert_array(int arr[], int &n, int val);
int main(){
int arr[CAPACITY] = {10,20,30,40,50,60,70,80,90,100};
int n = 10;
print_array(arr, n);
insert_array(arr, n, 5);
print_array(arr, n);
insert_array(arr, n, 150);
print_array(arr, n);
insert_array(arr, n, 55);
print_array(arr, n);
return 0;
}
void print_array(int arr[], int n){
for(int i=0; i<n; i++){
cout<<arr[i]<<" ";
}
cout<<endl;
}
void insert_array(int arr[], int &n, int val){
int pos = -1;
int i=0;
while(arr[i]<val && i<n){
pos = i;
i++;
}
for(i=n; i>pos; i--){
arr[i] = arr[i-1];
}
arr[pos+1] = val;
n++;
}

Using C++ Insert elements into a partially filled array. a) Create a partially filled array of...
In java please :-)
12 values have been input into array yearlyValues. Output all 12 elements, with 4 per line. If the elements are 10 20 30 40 50 60 70 80 90 100 110 120, the output is: 10 20 30 40 50 60 70 80 90 100 110 120 Hints: • Use a for loop with increment i += 4, rather than ++i. • Inside the for loop, just print all four elements using four print statements. An...
using C language
Create an array of doubles with 5 elements. In the array prompt the user to enter 5 temperature values (in degree Fahrenheit). Do this within main. Create a user defined function called convert2Cels. This function will not return any values to main with a return statement. It should have parameters that include the temperature array and the number of elements. The function should convert the values for Fahrenheit to Celsius and save them back into the same...
The ExceptionLab class provided: – Creates an array of 100
elements and fills it with random numbers from 1 to 100. – It asks
the user for an index value between 0 and 99. – Prints the element
at that position. – If a number > 99 is entered by the user, the
class will abort with an ArrayIndexOutOfBoundsException • Modify
the ExceptionLab: – Add a try-catch clause which intercepts the
ArrayIndexOutOfBounds and prints the message: Index value cannot be...
11. In the 2-3 tree given below (i.e., NOT a 2-3-4 tree), execute insert(28), insert(99), and insert(58), in that order, making sure to rebalance after each insertion. Draw the resulting 2-3 tree after executing these operations. 45 20 70 30 60 80 90 2(4(10 11) (25) (40) (50 55) (65) (71 75)(85) (92 96
PLEASE HELP ME WITH THIS HOMEWORK. Create a template function that, given an array of elements of any template type, deletes an element on a given position. Submit in the standard format in Dropbox Hw 4 before the deadline. Example for insertion (needs a fix!!! - 1st e-mail gets extra-credit) #include <iostream> using namespace std; // A template function to implement element insertion on given position in array. template <class T> void insert(T a[], int &n,T el, int place )...
In C Write a couple of functions to process arrays. Note that from the description of the function you have to identify what would be the return type and what would be part of the parameter. display(): The function takes an int array and it’s size and prints the data in the array. sumArray(): It takes an int array and size, and returns the sum of the elements of the array. findMax(): It takes an int array and size, and...
Trace the execution of quicksort on the following array, assuming that the first item in each subarray is the pivot value. Show the values of first and last for each recursive call and the array elements after returning from each call. Also, show the value of pivot during each call and the value returned through pivIndex. How many times is sortcalled, and how many times is partition called? 55 50 10 40 80 90 60 100 70 80 20 50...
A max-heap with 10 elements is given in the following array format. The following three sub-questions all refer to this max heap. i 1 2 3 4 5 6 7 8 9 10 A[i] 99 90 80 70 60 50 40 30 20 10 Show the result after applying heap-increase-key(A, 9, 95) to the max-heap at the top of this page: i 1 2 3 4 5 6 7 8 9 10 A[i] Show the result after applying heap-extract-max(A) to...
SQL Create an access database named student11. Create a table named student12 and insert the following records in it. ID StudentName Grade 1 John 90 2 Jim 70 3 Larry 85 4 Sally 20 5 Sam 60 6 Sandra 100 7 Runa 55 8 Simran 35 9 Seema 65 10 Ramu 75 Create a query to find students whose grade are more than or equal to 80.
Identify which of these four mass spectra indicate the
presence of sulfur, chlorine, bromine, iondine, nitrogen. suggest a
molecular formula for each.
2otten breaks sh ass spec er be mass PROBLEM 12-7 Identify which of these four mass spectra indicate the presence of sulfur, chlorine bromine, iodine, or nitrogen. Suggest a molecular formula for each. AA gIve the lonica 100 77 80 156 158 (a) 60 40 20 Fragn 10 20 30 40 50 60 70 80 100 110 120...