C++ Code:
#include<iostream>
using namespace std;
// function named findTarget that takes three parameters:
// numbers, an array of integers
// size, an integer representing the size of array
// target, a number
bool findTarget(int numbers[], int size, int target)
{
int i;
for( i = 0 ; i < size ; i++ )
// if the element is found
if( numbers[i] == target )
return true;
// if the element is not found
return false;
}
// myArray, an array of doubles
// size, an integer representing the size of array
// The function returns the smallest value in the array
double minValue(double myArray[], int size)
{
int i;
double min = myArray[0];
for( i = 1 ; i < size ; i++ )
if( myArray[i] < min )
min = myArray[i];
return min;
}
void fillAndFind(int numArray[], int length)
{
cout<<"Enter "<<length<<" number : ";
int i;
for( i = 0 ; i < length ; i++ )
cin>>numArray[i];
}
int main()
{
int numbers[] = { 1, 2, 3, 4, 5, 6, 7 };
double myArray[] = { 1.2, 5.6, 2.46, 3.5, 7.8 };
int numArray[6];
if( findTarget( numbers, 7, 5 ) )
cout<<"5 is present in array.";
else
cout<<"5 is not present in array.";
double min = minValue(myArray, 5);
cout<<"\nMin value : "<<min<<endl<<endl;
fillAndFind(numArray, 6);
int i;
cout<<"numArray : ";
for( i = 0 ; i < 6 ; i++)
cout<<numArray[i]<<" ";
return 0;
}
Output:
In c++ 1. Write a function named findTarget that takes three parameters - numbers: an array...
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 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.
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...
Write a C++ function, lastLargestIndex that takes as parameters an int array and its size and returns the index of the "last occurrence" of the largest element in the array. Include another function to print the array. Also, write a program to test your function. [HINTS) Create an array of size 15 in the main function and initialize it with the values shown in the below sample output. Pass the array and its size to function lastLargestindex; function lastLargestindex returns...
(C++) Write a function, remove, that takes three parameters: an array of integers, the number of elements in the array, and an integer (say, removeItem). The function should find and delete the first occurrence of removeItem in the array. (Note that after deleting the element, the number of elements in the array is reduced by 1.) Assume that the array is unsorted. Also, write a program to test the function. Your program should prompt the user to enter 10 digits...
Program must be wriiten in c++ Write a function, removeAt, that takes three parameters: an array of integers, the number of elements in the array, and an integer (say, index). The function should delete the array element indicated by index. If index is out of range or the array is empty, output an appropriate message. (Note that after deleting the element, the number of elements in the array is reduced by 1.) Assume that the array is unsorted.
Write a C function named isSymmetric, the prototype of which is given below, that returns 1 if the elements of an array of integers named myArray of size n are symmetric around the middle. If the array elements are not symmetric, the function should return 0. Both the array and its size are specified as parameters.
Question 14; Write a C function named isSymmetric, the prototype of which is given below, that returns 1 if the elements of an array of integers named myArray of size n are symmetric around the middle. If the array elements are not symmetric, the function should return 0. Both the array and its size are specified as parameters. (10 marks) Clue: Array myArray of size n is symmetric if myArray[0] is equal to myArray[n-1], myArray[1] is equal to myArray[n-2], and...
(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...