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
Art [367]
3 years ago
12

Write a method called all Less that accepts two arrays of integers and returns true if each element in the first array is less t

han the element at the same index in the second array. For example, if the two arrays passed are {45, 20, 300} and {50, 41, 600}, your method should return true. If the arrays are not the same length, you should return false.Test your method and print out to the screen in main() function the following callsa. all Less(arr1, arr2); (where arr1 = [1,2,3,4,5], arr2 = [4,5,6,7,8])b. all Less(arr1, arr2); (where arr1 = [1,2,3,4,5], arr2 = [5,6,7,8])c. all Less(arr1, arr2); (where arr1 = [5,2,3,4,1], arr2 = [4,5,6,7,8])d. all Less(arr1, arr2); (where arr1 = [5,5,3,4,5], arr2 = [9,9,9,9,1])
Computers and Technology
1 answer:
GaryK [48]3 years ago
8 0

Answer:

The program to this question can be given as:

Program:

#include<iostream> //header file

using namespace std; //using name space

bool allLess (int arr1[], int arr2[]) //defining method allLess  

{

int a,b; //define variable

a=  *(&arr1 + 1) - arr1; //hold length of arr1

b=  *(&arr2 + 1) - arr2; //hold length of arr2

if(a!=b) //checking condition  

{

return 1; //return value

}

for(int i=0; i<a; i++) //loop

{

if( arr1[i]>=arr2[i]) //checking condition

{

return 1; //return value

}

}

return 0; //return value

}

int main() //define main method.

{

   int arr1[]={1,2,3,4,5}; //define array arr1 and assign value.

   int arr2[]={4,5,6,7,8}; //define array arr2 and assign value.

   cout<< allLess(arr1,arr2); //function calling

   return 0;

}

Output:

1

Explanation:

The Explanation of the C++ language program can be given as follows:

  • In the above program firstly we include the header file. Then a method is defined that is "allLess" this method accepts two arrays that are "arr1 and arr2". This function returns a boolean value that is true or false.
  • Inside a function, we define a conditional statement and a loop in the if block we check the length of the arr1 array variable is not equal to arr2 array length. if this condition is true it will return false.
  • In the loop, we define another if block in this block we check that if arr1 array elements are grater then equal to arr2 array element if this condition is true it will return false. At the end of both if block and loop the function will return a value that is "true".
  • In the main method, we define two arrays and pass to the function and use (cout function) for print return value.
You might be interested in
Please anyone, help me.... I'm not sure how to put these all together.<br> 35 points!
Vilka [71]

Answer:

#School Name

school_name = "Klein Cain"

# Asks for name

full_name = input("Please enter your full name ")

#Says Hello

print("Hello, ", full_name, "!!")

#Says the letters in your name

print("There is ", len(full_name), " letters in your name")

#Says final message

print("??? is a Cain where??? ", school_name)

7 0
3 years ago
Read 2 more answers
Often duties and taxes are imposed on cars that are imported fron other countries. What type of incentives are these duties and
Kipish [7]

These duties and taxes are charged on imported cars in order to incentivize the people to purchase vehicles built in the home county instead.

6 0
3 years ago
Which of these is an example of an integrated presentation?
elena-14-01-66 [18.8K]
D because integration means that u are almost weaving it into something else so an excel chart into a power point is weaving them together
3 0
3 years ago
Consider two vectors that are NOT sorted, each containing n comparable items. How long would it take to display all items (in an
Darina [25.2K]

Answer:

The correct answer to the following question will be "Θ(​n​2​)

". The further explanation is given below.

Explanation:

If we're to show all the objects that exist from either the first as well as the second vector, though not all of them, so we'll have to cycle around the first vector, so we'll have to match all the objects with the second one.

So,

This one takes:

= O(n^2)

And then the same manner compared again first with the second one, this takes.

= O(n^2)

Therefore the total complexity,

= Θ(​n​2​)

7 0
3 years ago
What's is flow chart?
TEA [102]

Answer: A flowchart is a graphical representation of decisions and their results mapped out in individual shapes.

Explanation:

These shapes were first developed by Herman Goldstine and John von Neumann in the 1940s.

Flowcharts can provide a step-by-step diagram for mapping out complex situations, such as programming code or troubleshooting problems with a computer.

4 0
3 years ago
Other questions:
  • To extend the bottom border of a hyperlink across the complete width of a navigation list, change the ____ property of each hype
    9·1 answer
  • Which of the following is NOT an argument used to determine how a shot is fired from an A. object the shot itself being instanti
    12·1 answer
  • Which key should you press and hold to select multiple cells?
    8·2 answers
  • Whats wrong with my code for .addEventListener
    11·1 answer
  • Simplify 0.2×0.03055 to 3 decimal places​
    15·2 answers
  • Your computer is taking longer than usual to open files and you notice that your hard drive light stays on longer than usual whi
    9·1 answer
  • What is the main difference between weathering, erosion and leaching​
    9·1 answer
  • In this lab, you complete a C++ program that uses an array to store data for the village of Marengo.
    8·1 answer
  • What is computer specification
    15·1 answer
  • Compare the freedom available to the American media with the freedom available to media in other parts of the world. How does a
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!