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.