ANSWER: Here I am giving you the code and output if you have any problem then you can comment or like my solution.
CODE:
#include <iostream>
using namespace std;
int insertInArray(int list[],int index, int *numItems,int arrayCapacity, int newVal)
{
if(index>arrayCapacity)
return -1;
else
{
for(int i=arrayCapacity; i>index; i--)
{
list[i]=list[i-1];
}
list[index]=newVal;
return 0;
}
}
int main()
{
int list[4]={9,8,3};
int index, newVal;
cout<<"Enter an index to insert element :";
cin>>index;
int numItems=0;
for(int i=0;i<4;i++)
{
if(list[i]!=NULL)
numItems++;
}
int arrayCapacity=4;
cout<<"Enter your value to insert :";
cin>>newVal;
cout<<"\nArray before Inserting the new value.";
for(int i=0;i<4;i++)
{
if(list[i]!=NULL)
cout<<list[i]<<" ";
}
int rs=insertInArray(list,index,&numItems,arrayCapacity,newVal);
if(rs<0)
cout<<"You can not insert the value array is full or wrong index you entered.";
else{
cout<<"\nArray after Inserting the new value.";
for(int i=0;i<4;i++)
cout<<list[i]<<" ";
}
}
OUTPUT:
Must be C++ 11 Write a function named insertinArray that takes the following parameters: list: an...
Write a function named insertBeforeKey that takes the parameters as follows list as an char array, capacity for the capacity of the array, numItems has the number of items in the array, key is an element of the array before which newVal is to inserted. Assume key is always present in the array. and newVal has the new value to be inserted into the array. If the array is at capacity then the function should return -1, otherwise return 0...
Define a function named insert that takes an integer atom and a sorted list as parameters. The function should return a list with the integer in the correct position in the sorted list. For example: insert [3, (2 4 6 8)] = (2 3 4 6 8) insert 9, ()] = (9) insert[3, (2 3 4 5)] = (23 3 4 5) Note that in the case of that last example, it does not matter which 3 comes first in...
1. Write a function named findTarget that takes three parameters: numbers, an array of integers - size, an integer representing the size of array target, a number The function returns true if the target is inside array and false otherwise 2. Write a function minValue that takes two parameters: myArray, an array of doubles size, an integer representing the size of array The function returns the smallest value in the array 3. Write a function fillAndFind that takes two parameters:...
Write a function named findTarget that takes three parameters: - numbers, an array of integers - size, an integer representing the size of array - target, a number The function returns true if the target is inside array and false otherwise
Write a C++ function, smallestIndex, that takes as parameters an int array and its size and returns the index of the first occurrence of the smallest element in the array. To test your function, write a main that prompts a user for a list of 15 integers and outputs the index and value of the first occurrence of the smallest value. The program should print out Enter 15 integers: The position of the first occurrence of the smallest element in...
In c++ 1. Write a function named findTarget that takes three parameters - numbers: an array of integers size: an integer representing the size of array target: a number The function returns true if the target is inside the array and false otherwise 2. Write a function min Valve that takes two parameters: myArray an array of doubles - size: an integer representing the size of array The function returns the smallest value in the array 3 Wrile a funcion...
help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and an int parameter. If both string parameters represent binary numbers and the int parameter is equal to a positive number less than or equal to the length of the longest string parameter, the function should return a binary string whose length is equal to two times the length of the maximum length of the two string parameters whose value is equal to the sum...
Write a function named stats, that takes an array and the number of elements in the array as arguments. It must compute and print the minimum value in the array, maximum value in the array and the average value of all the values inside the array. Your function MUST be named stats Your function has two parameters in the following order: an array of type double The number of elements in the array, type int Your function should NOT return...
(C++) Write a function, insertAt, that takes four parameters: an array of integers, the number of elements in the array, an integer (say, insertItem), and an integer (say, index). The function should insert insertItem in the array provided at the position specified by index. If index is out of range, output the following: Position of the item to be inserted is out of range or if the index is negative: Position of the item to be inserted must be nonnegative...
Write a function named numPerfect that takes as parameters: an array of integer scores between zero and 100 (inclusive) the size of the array and returns the number of perfect scores in the array. Also write a main function that creates and initializes an array of ints (in the appropriate range), calls the function with that array, and prints out the return value.