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
How long will it take Lola to travel from Paris to nice?
Alisiya [41]

the answer is 5,000 hours.

I recommend you post these kind of questions in the mathematics section

4 0
4 years ago
Which payment method typically charge is the highest interest rates?
jek_recluse [69]

The highest amount is Credit. The more you wait the higher the interest, higher the interest the more you pay, and no one wants to play more. Stay safe use debit as much as you can

8 0
3 years ago
What is Hypertext Transfer Protocol?
densk [106]

Answer:

B

Explanation:

Web browsers use HTTP to send and receive information to and from the web.

3 0
4 years ago
If the programmer translates the following pseudocode to an actual programming language, a syntax error is likely to occur. Can
maxonik [38]

Answer:

if, then, else

Explanation:

you specified that if you enter award for 1st prize then it'll display 1st prize but you didnt specify what will happen if user does not enter 1st prize or what happens if 1st prize is not allocated. To me it looks like you got the 'if' and 'then' part correct but you dont have a 'else' part to it therefore it'll create an error when its not declared.

8 0
3 years ago
If you’re torn between more than one option while making a decision, which of the following would most likely be the best strate
Vladimir [108]
<span>If you’re torn between more than one option while making a decision, which of the following would most likely be the best strategy to help you decide you should get rid of the bad ones and you will be left with good ones 

</span>
3 0
3 years ago
Other questions:
  • Developers work together with customers and useras to define requirements and specify what the proposed system will do. If once
    9·1 answer
  • An airline company would like to easily locate lost luggage. What technology would make it easier for them to locate the luggage
    6·2 answers
  • Who invented the first RAM stick
    11·1 answer
  • PLEASE HELP
    6·1 answer
  • Please help due today please help me!!!!!
    15·1 answer
  • Explain the role of the network layer and Internet protocol (IP) in order to make internetworking possible.
    8·1 answer
  • QUESTION 3 / 10
    10·1 answer
  • Write a program that keeps asking the user for new values to be added to a list until the user enters 'exit' ('exit' should NOT
    10·1 answer
  • Please answer questions in complete sentences!
    14·1 answer
  • An Accenture healthcare client is interested in implementing an Artificial Intelligence (AI) solution to improve patient care, b
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!