Question

C++ program for :

1. Given an array of real numbers and the dimension n (n is
entered from the keyboard). B form an array, each element bi -
arithmetic mean of the array elements and excluding ai.

2. Given an array of integers dimension n. Change the array so that
all the elements of the module which is not equal to the maximum
element of the array, replaced by zero, and equal - unit.

3. Given an array of dimension n (even). If the array elements in
ascending order, to remove the elements of the array by one,
starting with the first, or - insert into the middle element of the
array is equal to the first, "contrary to" the condition of the
increase. An additional array can not be used.

4. Dana matrix of nxm. Get a one-dimensional array a [m], keeping
the sum of the elements corresponding to the columns of which are
prime numbers.

Answer #1

Here are the functions for the first 2 methods.

#include <iostream>

using namespace std;

//1. Given an array of real numbers and the dimension n (n is
entered from the keyboard).

//B form an array, each element bi - arithmetic mean of the array
elements and excluding ai.

double* arrayOfMeans(double array[], int n)

{

double *newArray = new double[n];

double sum = 0.0;

for(int i = 0; i < n; i++)

sum += array[i];

for(int i = 0; i < n; i++)

newArray[i] = (sum - array[i]) / n-1;

return newArray;

}

//Given an array of integers dimension n. Change the array so that
all the elements of the

//module which is not equal to the maximum element of the array,
replaced by zero, and equal - unit.

void modifyElementsOfArray(int array[], int n)

{

int maxElement = array[0];

for(int i = 1; i < n; i++)

if(array[i] > maxElement)

maxElement = array[i];

for(int i = 0; i < n; i++)

if(array[i] != maxElement)

array[i] = 0;

else

array[i] = 1;

}

C LANGUAGE CODE WITH COMMAND-LINE ARGUMENTS (NO
SCANF TO BE USED )
Q]. Write a program that displays all
the prime numbers in the given array with the following
constraint.
Constraint: Only those prime numbers should be
displayed whose location is a composite number.
Although you may have several prime numbers in the array, only
those prime numbers should be displayed which are stored at
non-prime locations. Remember that the first position in an array
corresponds to the location/index 0....

Write a code in c++ using linear insertion following the steps
below. Comment your work.
1. Ask the user for the name of a file containing
data. If it does not exist, the program should display an error,
then ask for a new file name. Entering an asterisk (*) as the first
and only character on a line should terminate the program.
2. You can use a statically-allocated
one-dimensional array of doubles for this with length 100. You...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 14 minutes ago

asked 14 minutes ago

asked 24 minutes ago

asked 31 minutes ago

asked 40 minutes ago

asked 45 minutes ago

asked 45 minutes ago

asked 47 minutes ago

asked 54 minutes ago

asked 56 minutes ago

asked 56 minutes ago

asked 57 minutes ago