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
ANSWER QUICKLY!!! <br><br> What is an advantage of digital portfolios?
algol13
Easy to carry or utilize
8 0
2 years ago
How do you take a picture underwater with my phone that is not waterproof?
LenaWriter [7]

Answer:

try putting it in a clear glass cup or sealing it tightly in a zip lock bag

Explanation:hope i helped love yall and can iget brainliest i only need two more

6 0
3 years ago
What part of a waveform describes a sound's loudness?
torisob [31]

Answer:

B i believe

Explanation:

3 0
4 years ago
Read 2 more answers
Which of the following would be the correct si unit to use in measuring the amount of electrical current in a circuit
rjkz [21]

I think its joule i hope this helps

4 0
3 years ago
Read 2 more answers
You need to find out more about the f disk utility and the commands associated with it before you set up a new Linux system in a
nexus9112 [7]

Answer:

The answer is "Option a"

Explanation:  

Fdisk command is part of Linux and Unix systems, this command is used to format or fixed a disk, this command is mainly used in the command-line program, that provides a view, update, delete, modify, copy and paste into another partition of the hard drive, through a user-focused menu-driven interface with fdisk command, and wrong choices can be described as follows:

  • In option b, This command is used to provide more information about another command, that's why it is incorrect.
  • In option c, This command is used to find the location and partitioning the disk, that's why it is wrong.
8 0
3 years ago
Other questions:
  • Assume that a program consists of integer and floating-point instructions. 60% of the total execution time is spent on floating
    7·1 answer
  • Which activity constitutes legal computer activity?
    12·1 answer
  • What type of malicious software masquerades as legitimate software to entice the user to run it?
    14·1 answer
  • What features do you think that a smart fridge should have? Please give me a quick answer! And in detail.
    13·1 answer
  • Releasing refrigerator R -12 into the atmosphere is a criminal offense. A)true B) false
    5·2 answers
  • What is the meaning of heart symbol in facebook?
    14·1 answer
  • David is preparing a report to show the percentage increase in population in the United States in the last five years. Which fea
    12·1 answer
  • WILL CHOOSE BRAINLIEST! in cells D6 through D8, enter formulas to calculate the values of the stocks. The formulas should multip
    6·1 answer
  • What job does a front-end developer perform?
    15·1 answer
  • What makes a recipe for a meal an example of an algorithm?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!