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
What privacy risks do new technologies present,<br> and how do we decide if they're worth it?
vredina [299]

Answer:

Los riesgos de las nuevas tecnologías se multiplican a medida que nos hacemos dependientes de ellas. También lo hacen a medida que sustituyen a otras formas de contacto social más cercanas

Los riesgos de las nuevas tecnologías son grandes desconocidos. El mal uso de las redes sociales y de Internet en los ordenadores y en el teléfono móvil, entre otros factores, supone un peligro real para todos los estratos de población, pero en especial para los más jóvenes. Pensemos, ¿realmente somos conscientes de los riesgos que suponen las nuevas tecnologías? ¿Sabemos cómo utilizarlas para no ponernos en riesgo?

Cabe destacar que las denominadas nuevas tecnologías de la información y de la comunicación (TICs) son un distintivo de la época actual y se han convertido en herramientas esenciales en las diferentes áreas de la vida. Esto es, para el área académica, laboral, social, de ocio…

En la mayoría de los ámbitos están presentes las TICS, pues incluyen las diferentes herramientas con las que nos manejamos hoy en día: servicios de contacto electrónico (e-mails, servicios de mensajería instantánea, chats), los teléfonos móviles, tablets y ordenadores, las plataformas online de difusión de contenidos, las redes sociales, entre otros..

Explanation:

6 0
3 years ago
What phrase best describes the overall structure of the<br> passage
creativ13 [48]

Answer: The one that gives you more vibe that its correct.

Explanation:

3 0
3 years ago
A customer dictates instruction on how to transcribe audio. Do you have to transcribe the instruction word for word?
Ostrovityanka [42]

Answer:

No

Explanation:

4 0
2 years ago
The Occupational Outlook Handbook is published by the Bureau of Labor Statistics.
nika2105 [10]
HEY THEIR

The correct answer is A. true.

It was written in 1948 by the bureau of Labor statistics .

HOPE IT HELPS YOU
7 0
3 years ago
Which are resources that a programmer might use? Select all that apply.
Hoochie [10]

Answer:

online help and user forums iam not sure of this amswer maybe

5 0
3 years ago
Read 2 more answers
Other questions:
  • Which answer best describes an unsubsidized federal loan
    9·1 answer
  • Jackson is teaching the decimal number system. He wants his students to know how to expand numbers by powers of 10. Which is the
    13·2 answers
  • Professional photography is a competitive job field. <br> true <br> false
    12·2 answers
  • When might be the best time to start saving for retirement?
    5·2 answers
  • A Network Attached Storage device is good for _____.
    11·2 answers
  • Rerouting traffic using arp poisoning is an attack on ________ of a network.
    8·1 answer
  • _____________ describes the abstraction of web-based computers, resources, and services that system developers can utilize to im
    9·1 answer
  • What movie would be greatly improved if it was made into a musical?
    6·1 answer
  • Imagine you are responsible for making a presentation that includes a representation of the logic flow through a process. You un
    11·1 answer
  • When was the first analog device, the phonautograph, launched?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!