1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
atroni [7]
3 years ago
11

Write a program to randomly fill an array of float of 10 elements (use the rand() function and make sure to use #include ) in ma

in then define a function to find the maximum element in the array using pointers and return the max element to main then print it on screen.
Computers and Technology
1 answer:
Lilit [14]3 years ago
4 0

Answer:

#include <iostream>

#include <stdlib.h>

#include <time.h>

using namespace std;

// array fill and returnig array to the main()

float *arrayFill(float *arr) {

// srand() allows generate new random value everytime the program runs

srand(time(NULL));

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

{

 // array fill with random number between 0 to 100

 arr[i] = (rand() % 100);

}

return arr;

}

// print array

void print(float* arr) {

cout << "Array:  ";

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

{

 cout << arr[i] << "   ";

 

}

}

float maxNum(float* arr) {

float temp = arr[0];

for (int i = 1; i < 10; i++) {

 if (temp < arr[i]) {

  temp = arr[i];

 }

}

return temp;

}

int main() {

// creating dynamic array of elements 10 in heap memory

float *arrPtr = new float[10];

float result = 0;

// calling arrayFill()

arrPtr = arrayFill(arrPtr);

// calling print() to print array

print(arrPtr);

// calling maxNum() to find maximum number in the array

result = maxNum(arrPtr);

cout << "\nmaximum number: " << result;

delete[] arrPtr;

return 0;

}

Explanation:

please read inline comments inside the code section:)

You might be interested in
When a support agent does not know the answer to a question, a good incident management strategy is to tell the user ____.
laiz [17]

When you don't know the answer to a question, a good incident management strategy is to tell the user that you'll research the question and get back to him or her.

<h3>What is incident management?</h3>

Incident management can be defined as a strategic process through which a business organization or company identifies, analyzes, and correct hazards, so as to ensure that normal service operation is restored as quickly as possible to end users after a disruption, as well as to prevent a re-occurrence of these hazards in the future.

As a support agent, if you don't know the answer to a question, a good incident management strategy is to tell the user that you'll research the question and get back to him or her at a latter time.

Read more on incident management here: brainly.com/question/11595883

4 0
2 years ago
Databases offer many security features including passwords to provide authentication, access levels to determine who can access
Murljashka [212]

Answer:

True

Explanation:

When using databases in a project, not everyone has the same access level, e.g the database admin may have the highest level of access (access to data on live mode), the software testers have their own level of access (access to data on test mode) and so on.  

7 0
3 years ago
Which of the following statements is true of infrastructure?
bazaltina [42]

Answer:

Examples of infrastructure include transportation systems, communication networks, sewage, water, and electric systems. Projects related to infrastructure improvements may be funded publicly, privately, or through public-private partnerships.

3 0
1 year ago
What materials where used to make the first gps
8090 [49]
You need a radio transmitter that transmits some kind of radio wave signal, and an array of satelites to compare the postion to other parts of the world.
Hope this helps!
8 0
2 years ago
The _______ provides access to the internet; may also be internal?
VikaD [51]
World Wide Web (WWW)? I honestly don't know.
8 0
2 years ago
Other questions:
  • How can i add card reader to pc answers?
    9·1 answer
  • If you are upgrading your operating system to Windows 7, you may not use the In-Place Upgrade Installation Option with
    14·1 answer
  • Choose the word that best completes this sentence. ____________ should cover every part of the worksite.
    10·2 answers
  • Alice is working on a web page to attract the maximum number of people to join her cause. She wants to inform people about the b
    12·1 answer
  • What specific record type is found in every zone and contains information that identifies the server primarily responsible for t
    10·1 answer
  • 10. This famous designer’s sister took over his clothing line after his assassination in 1997.
    9·1 answer
  • Sue follows these steps to create a chart in her presentation.
    13·1 answer
  • If anyone gotta ps4, i'm a 15 yr old female n if u wanna b frens, hmu :))
    8·2 answers
  • Write a program that reads 20 integers from the user into an array and uses a function arrayMinimum that accepts an integer arra
    5·1 answer
  • Moving images of real event​
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!