#include <bits/stdc++.h>
using namespace std;
int fillAndFind(int a[], int n)
{
cout<<"Enter "<<n<<" value in the
array: \n";
int c=0;
for(int i=0;i<n;++i)
{
cin>>a[i];
if(a[i]%2!=0)
c++;
}
return c;
}
bool findTarget(int a[], int n, int t)
{
for(int i=0;i<n;++i)
{
if(a[i]==t)
return 1;
}
return 0;
}
double minValue(double arr[], int n)
{
double m=100000.0;
for(int i=0;i<n;++i)
{
if(m>arr[i])
m=arr[i];
}
return m;
}
int main()
{
int n;
cout<<"Enter the size of the array you want:
";
cin>>n;
int a[n];
int numberOfOdds=fillAndFind(a,n);
cout<<"Number of Odd values in the array is
"<<numberOfOdds<<"\n";
int a1[n];
cout<<"Enter "<<n<<" integers for
next array: \n";
for(int i=0;i<n;i++)
{
cin>>a1[i];
}
cout<<"Enter a number you want to find in the
array: ";
int t;
cin>>t;
bool x=findTarget(a1,n,t);
if(x==1)
cout<<"True"<<endl;
else
cout<<"False"<<endl;
double arr[n];
cout<<"Enter "<<n<<" doubles for
next array: \n";
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
double m=minValue(arr,n);
cout<<"Minimum value is:
"<<m<<endl;
return 0;
}
The answers have been
provided in accordance with the questions asked and how I have
percieved the question. I have tried my best to answer upto your
satisfaction. If you are satisfied with the answer, kindly like
it.
Also, if you face any kind of problem regarding the solution,
please feel free to comment and I shall answer to my best
knowledge. Please do not dislike this answer without clarifying the
doubts.
Thank you.
1. Write a function named findTarget that takes three parameters: numbers, an array of integers -...
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...
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 function named "eliminate_duplicates" that takes an array of integers in random order and eliminates all the duplicate integer integers in the array. The function should take two arguments: (1) an array of integers; (2) an integer that tells the number of cells in the array. The function should return the number of distinct integers in the array.
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...
JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a parameter. This method calculates and returns the largest even number in the list. If there are no even numbers in the array, the method should return 0. You can assume that the array is not empty. For example: Test Result int[] values = {1, 4, 5, 9}; System.out.println(getMaxEven(values)); 4 System.out.println(getMaxEven(new int[]{1, 3, 5, 9})); 0 public static int --------------------------------------------------------------------------------- 2. Write a static method...
(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...
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...