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
Send the memes whoever is the best will get that crown thing lol
shutvik [7]
I have to type 20 characters here so...

4 0
4 years ago
Read 2 more answers
Why do primitive types have ranges of values? what determines the range of the data type?
Alexxx [7]
What determines the range of primitive data types is a combination of the number of bytes that is allocated to them and if there's any encoding.

Not too long ago, it was normal for an integer to receive four bytes of memory. An unsigned integer would also receive four bytes of memory. The unsigned int  had a range of 0 - (2^32 - 1) because it could only be used for positive integers and could use all 32 bits. An integer has a range of (- 2^31 through +2^31 - 1). The 32nd bit is uses as a sign bit (0 for positive, 1 for negative).

Just for thoroughness: when an int is negative, it's stored as the two's complement of it's absolute value.
5 0
3 years ago
Exercise : Randomizer In this exercise, we are going to create a static class Randomizer that will allow users to get random int
Nutka1998 [239]

Answer:

Here the code is by using java.

Explanation:

//Randomizer.java

public class Randomizer {

public static int nextInt() {

//get random number from 1-10

int randInteger = (int) (Math.random() * (11) + 1);

//if number is greater than 10 or less than 1

while (randInteger > 10 || randInteger < 1) {

randInteger = (int) (Math.random() * (11) + 1);

}

return randInteger;

}

public static int nextInt(int min, int max) {

//formula to get random number from min-max

int randInteger = (int) (Math.random() * (max + 1) + min);

while (randInteger > max || randInteger < min) {

randInteger = (int) (Math.random() * (max + 1) + min);

}

return randInteger;

}

}

//RandomizerTester.java

public class RandomizerTester {

public static void main(String[] args) {

System.out.println("Results of Randommizer.nextInt()");

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

System.out.println(Randomizer.nextInt());

}

int min = 5;

int max = 10;

System.out.println("\n Results of Randomizer.nextInt(5,10)");

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

System.out.println(Randomizer.nextInt(min, max));

}

}

}

OUTPUT:

Results of Randommizer.nextInt()

9

2

3

8

5

9

4

1

9

2

Results of Randomizer.nextInt(5,10)

9

8

9

7

5

10

5

10

7

7

4 0
3 years ago
You are troubleshooting a computer that is in the design phase. The problem you see is that the CPU is not receiving information
IgorC [24]

Answer:

The correct option of the following question is c). control bus.

Explanation:

A control bus is a bus of the computer system which is use by the CPU(Central Processing Unit) to communicate with the devices which are contained with the computer.

CPU transmits the variety of the control signals to devices and components to transmits the control signal to the CPU by using control bus. One of the main objective of the bus is to minimize lines which are needed for the communication.

3 0
3 years ago
Any task done by software can also be done using computer hardware, and any operation performed directly by hardware can be done
skad [1K]

Answer:

True.

Explanation:

A platform can be defined as a computing environment for building and executing sets of code in a software application or program such as an application programming interface (API).

The two parts of the platform used to run an application software are both hardware and operating system (software).

A hardware platform can be defined as a collection of hardware that are compatible with each other and the software application or program to be executed. All hardware platforms have their respective low level or high level machine language that are compatible with the software application. Some examples of a hardware platform are x86, i860, MIPS, video game consoles (joysticks), IBM Z, ARM, unisys, powerpc, SPARC etc.

An operating system platform is a system software pre-installed on a computing device to manage or control software application, computer hardware and user processes. Some examples of an operating system are QNX, Linux, OpenVMS, MacOS, Microsoft windows, IBM, Solaris, VM etc.

Hence, any task done by software can also be done using computer hardware, and any operation performed directly by hardware can be done using software.

6 0
3 years ago
Other questions:
  • The _________ check is a type of hardware control that involves adding a "1" or a "0" to the end of every 8 bit byte such that t
    11·1 answer
  • An “evil twin” in the context of computer security is: a) A virus-laden attachment that looks just like a sincere attachment b)
    5·1 answer
  • A disk drive’s data ____________________ rate is a summary performance number combining the physical aspects of data access with
    10·2 answers
  • What are the opportunities, and challenges, forged by digital transformation?
    13·1 answer
  • Knowing and understanding the targeted audience is a main compnent to creating a website
    15·1 answer
  • What is NOT a built-in function in python?<br> sqrt()<br> string()<br> fabs()<br> O print()
    12·2 answers
  • Why is it a good idea to restate in your own words what you heard someone say? It can reduce the chances of a miscommunication.
    11·1 answer
  • Subscribe to Markiplier
    15·2 answers
  • 8.10 Code Practice Question 3
    6·1 answer
  • WILL GIVE A BRAINLIEST!!! PLS HELP!!!
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!