Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

c++ help me plz as soon (by visual stdio ) a Write a program that will ask the u

ID: 3762703 • Letter: C

Question

c++ help me plz as soon (by visual stdio ) a

Write a program that will ask the user to enter the size of the array X, then do the following: Function (readArray): that will read N integers into an array x. Function (maxNum): that will find the maximum number in array X, count the frequency of the maximum number and the location of the first maximum number. Function (replaceEven): that will replace the even elements in the array X with the value 0. Function (printArray): that will print the values of array X. Sample Output Please enter array size: 10 Enter 10 numbers (+ev, -ev and zero): -2 5 7 -9 0 9 8 6 9 -5 Maximum number = 9 The maximum number is presented 2 times The first maximum number is at location 5 the values of the array after (replaceEven function is: 0 5 7 -9 0 9 0 0 9 -5

Explanation / Answer

#include<iostream>

#include<math.h>

using namespace std;

void readArray(int *X,int size)

{

cout << "Enter " << size << " numbers(+ve,-ve and zero): " ;

  

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

cin >> X[i];

}

void maxNum(int *X,int size)

{

int max = X[0];

int loc = 0;

int count = 0;

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

{

if(X[i]>max)

{

max = X[i];

loc = i;

}

}

  

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

if(max==X[i])

count++;

  

cout << " Maximum number is : "<<max;

cout << " Maximum number is presented " << count << " times.";

cout << " The first maximum number is at location " << loc << endl;

}

void replaceEven(int *X,int size)

{

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

if(X[i]%2==0)

X[i] = 0;

}

void printArray(int *X,int size)

{

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

cout << X[i] << " ";

cout << endl;

}

int main(){

  

int size;

cout << "Please enter the size of array : ";

cin >> size;

  

int X[size];

  

readArray(X,size);

maxNum(X,size);

printArray(X,size);

  

replaceEven(X, size);

cout << "The values of the array after calling (replaceEven) function is : ";

printArray(X,size);

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote