Question

c++ program need help Write a function allBigger that takes 3 parameters: 2 arrays of floats...

c++ program need help

Write a function allBigger that takes 3 parameters: 2 arrays of floats and an int that represents the length of each array
The function returns true if at every position, the value in the first array is strictly greater than the value in the 2nd array, false if not.
For example: {1.3, 7.4, 2.51} and {1.0, 2.1, 3.2} would return false because 2.51 < 3.2
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

bool allBigger(float arr1[], float arr2[], int size){
    for(int i = 0;i<size;i++){
        if(arr1[i]<=arr2[i]){
            return false;
        }
    }
    return true;
}

int main()
{
    float arr1[] = {1.3, 7.4, 2.51};
    float arr2[] = {1.0, 2.1, 3.2};
    
    if(allBigger(arr1,arr2,3)){
        cout<<"true";
    }
    else{
        cout<<"false";
    }
    return 0;
}

false

Add a comment
Know the answer?
Add Answer to:
c++ program need help Write a function allBigger that takes 3 parameters: 2 arrays of floats...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • c++ program need help Write a function allBigger that takes 3 parameters: 2 arrays of floats...

    c++ program need help Write a function allBigger that takes 3 parameters: 2 arrays of floats and an int that represents the length of each array The function returns true if at every position, the value in the first array is strictly greater than the value in the 2nd array, false if not. For example: {1.3, 7.4, 2.51} and {1.0, 2.1, 3.2} would return false because 2.51 < 3.2

  • c++ Write a function has Match that takes 3 parameters: 2 arrays of strings and an...

    c++ Write a function has Match that takes 3 parameters: 2 arrays of strings and an int that represents the length of each array The function returns true if at any position, the two arrays have the same string, false if not. For example: {"a", "b", "cat", "d"} and {"1", "2", "cat", "4"} would match

  • c++ question need help Write a function pairWise that takes four parameters: two arrays of int...

    c++ question need help Write a function pairWise that takes four parameters: two arrays of int and the size of the first array. The size of the first array is guaranteed to be exactly twice the size of the 2nd array The function takes each pair of integers from the first array and stores the product in the 2nd array. ex: if the first array is {2, 7, 3, 4}, then the second array will end up with {14, 12}

  • c++ question need help Write a function pairWise that takes four parameters: two arrays of int...

    c++ question need help Write a function pairWise that takes four parameters: two arrays of int and the size of the first array. The size of the first array is guaranteed to be exactly twice the size of the 2nd array The function takes each pair of integers from the first array and stores the product in the 2nd array. ex: if the first array is {2, 7, 3, 4}, then the second array will end up with {14, 12}

  • Write a C++ function, smallestIndex, that takes as parameters an int array and its size and...

    Write a C++ function, smallestIndex, that takes as parameters an int array and its size and returns the index of the first occurrence of the smallest element in the array. To test your function, write a main that prompts a user for a list of 15 integers and outputs the index and value of the first occurrence of the smallest value. The program should print out Enter 15 integers: The position of the first occurrence of the smallest element in...

  • Write a program with a function named isEqualArr that accepts a pair of arrays of integers...

    Write a program with a function named isEqualArr that accepts a pair of arrays of integers as parameters and returns true if the arrays contain the same elements in the same order. If the arrays are not the same length, your function should return false. For example, if the following arrays are declared: int[] arr1 = {10, 20, 30, 40, 50, 60}; int[] arr2 = {10, 20, 30, 40, 50, 60}; int[] arr3 = {20, 3, 50, 10, 68}; The...

  • write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy....

    write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...

  • A method called linearSearch(), which takes as parameters an array of int followed by three values...

    A method called linearSearch(), which takes as parameters an array of int followed by three values of type int, and returns a value of type int. The first int parameter represents a key, the second int parameter represents a starting position, and the third int parameter represents an end position. If the key occurs in the array between the start position (inclusive) and the end position (exclusive), the method returns the position of the first occurrence of the key in...

  • help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and...

    help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and an int parameter. If both string parameters represent binary numbers and the int parameter is equal to a positive number less than or equal to the length of the longest string parameter, the function should return a binary string whose length is equal to two times the length of the maximum length of the two string parameters whose value is equal to the sum...

  • 1. Write a function named findTarget that takes three parameters: numbers, an array of integers -...

    1. Write a function named findTarget that takes three parameters: numbers, an array of integers - size, an integer representing the size of array target, a number The function returns true if the target is inside array and false otherwise 2. Write a function minValue that takes two parameters: myArray, an array of doubles size, an integer representing the size of array The function returns the smallest value in the array 3. Write a function fillAndFind that takes two parameters:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT