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
Write a program that uses the function isPalindrome given in Example 6-6 (Palindrome). Test your program on the following string
Artist 52 [7]

Answer:

#include <bits/stdc++.h>

using namespace std;

bool isPalindrome(string str)

{

   char a,b;

int length = str.length();

for (int i = 0; i < length / 2; i++)

{

   a=tolower(str[i]);//Converting both first characters to lowercase..

   b=tolower(str[length-1-i]);

   if (b != a )

return false;

}

return true;

   

}

int main() {

   string t1;

   cin>>t1;

   if(isPalindrome(t1))

   cout<<"The string is Palindrome"<<endl;

   else

   cout<<"The string is not Palindrome"<<endl;

return 0;

}

Output:-

Enter the string

madam

The string is Palindrome

Enter the string

abba

The string is Palindrome

Enter the string

22

The string is Palindrome

Enter the string

67876

The string is Palindrome

Enter the string

444244

The string is not Palindrome

Explanation:

To ignore the cases of uppercase and lower case i have converted every character to lowercase then checking each character.You can convert to uppercase also that will also work.

6 0
3 years ago
Consider the following code:
Elis [28]

Answer:

return tmp;

default:

tmp . token_type = ERROR;

return tmp;

1. In the code, input.GetChar() gets the next character from standard input. If GetToken() is called four times, which of the following inputs will return a token whose type is ERROR?

A. ========

A. =<======

B. ===>====

C. =====<==

D. ======<=

5 0
3 years ago
You need to create the directory /var/oracle/database/9i. only the directory /var currently exists. from the root of the filesys
egoroff_w [7]
To create a directory, you can use the command mkdir. Below is an example:

mkdir /var/oracle/database/9i
3 0
4 years ago
CAN SOMEONE DO OR LOOK UP THE PIE CHART FOR THIS ANSWER PLS AND I WILL MARK YOU BRAINLIEST BUT PLSSS HELP MEEEE!!!
beks73 [17]

Answer:

I highly recommened you use ggl charts.

Explanation:

It's free. ALL YOU NEED IS AN GGL ACCOUNT. You can also choose many types of graph you want.

4 0
3 years ago
Differents<br>DIFFE<br>RENTIATE BETWEEN FORMULA &amp; A FUNCTION Giving Example​
wel

Answer:

?

Explanation:

3 0
3 years ago
Other questions:
  • What is connectivism and how does it apply to online learning?
    7·1 answer
  • What are the first and the last physical memory addressesaccessible using
    10·1 answer
  • You can change the transparency of a picture used as a slide’s background with the ____.
    10·1 answer
  • What is infinite recursion?
    7·1 answer
  • What are the two basic categories of film
    5·1 answer
  • What is the model for 2017 Ford Mustang v6
    15·1 answer
  • Complete the sentence with the correct response.
    12·1 answer
  • 1. Which of the following is not true about high-level programming language s? (a) Easy to read and write (b) Popular among prog
    12·1 answer
  • Keith would like to compare data he has collected from research. The data includes the electrical output
    13·1 answer
  • As part of your regular system maintenance, you install the latest operating system updates on your Windows 10 computer. After s
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!