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 can you turn on a light switch and it not work, without turning off the power to the whole house?
vitfil [10]

Answer:

Go to the beaker box and turn off the power to that one room. Duh

Explanation:

6 0
3 years ago
To be a successful computer systems engineer, you must be proficient in programming languages and operating systems. Similarly,
Maslowich

Collectively, skills like the ones listed above are Technical skills. These skills refer to the Knowledge and ability to perform specific tasks. However, Soft skills are also important, because they relate to the ability to interact and communicate effectively with people.

6 0
4 years ago
Read 2 more answers
What is the name of the the world cell of the internet?​
kipiarov [429]
<h2>Mobile Web</h2>

How you even don't know the basic information

it's disgusting.

3 0
3 years ago
Stanovte intenzitu magnetického poľa v strede tenkej cievky s 20 závitmi. Prúd je 2A , stredný polomer cievky je 4cm.
ExtremeBDS [4]

Answer:

Determine the intensity of the magnetic field in the center of a thin coil with 20 turns. The current is 2A, the mean radius of the coil is 4cm.

Explanation:

to help english help you

4 0
3 years ago
Why can't I register for Brainly?? I've been trying for months, too! I've noticed this question has been asked so many times, bu
Alenkasestr [34]

Answer:

Just click view profile and go to preferences

Heres a screenshot :

4 0
3 years ago
Other questions:
  • On the CallCenterReport worksheet, add formulas that will summarize the issues for the department entered in cell B3. In cell B6
    13·1 answer
  • What does the hexadecimal number 2D represent in the binary system?
    9·1 answer
  • What is the name of the keyboard developed in the 1930s?
    13·1 answer
  • What type of graphic organizer will help jane compare the results of a student survey about teachers at her school?
    15·2 answers
  • Is main memory fast or slow?
    9·1 answer
  • An investment website can tell what devices are used to access the site. The site managers wonder whether they should enhance th
    10·1 answer
  • SOMEBODY HELP ME ASAP PLEASE AND THANK YOU
    14·2 answers
  • Select the correct answer.
    5·1 answer
  • Write a function float Average(int, int) that finds the mean, and then write a main program that inputs two numbers from the use
    7·1 answer
  • What information most likely presents a security risk on your personal
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!