Hi there,
I'm bit frustrated to see that your website has a same question posted many times but no solution.
Why? I have purchased subscription to get solution that claimed on your page. Why I can\t see the solution?
For example, the following Question doesn't have a solution:
Write a function, equalsArray that when passed two int arrays of the same length that is greater than 0 will return true if every number in the first array is equal to the number at the same index in the second array. If the length of the arrays is less than 1 the function must return false. For example, comparing the two arrays, {1,2,3,4,5} and {1,2,3,4,5} would return true but the two arrays {3,7} and {3,6} would return false.
You should start by copying the function-1-1.cpp file and name it function-3-1.cpp. Then add the function equalsArray to the new file.
The main function for this problem must call your readNumbers function twice, then pass both new arrays to your equalsArray function, display the result as true or false and finally delete the array. The main function in the file main-3-1.cpp.
The signature for your new function is:
bool equalsArray(int *numbers1,int *numbers2,int length) ;
function-3-1.cpp contents:
#include<iostream>
using namespace std;
// This function reads values into arr
void readNumbers(int* arr,int length)
{
for(int i=0;i<length;i++)
{
cout<<"Enter value to store
at index "<<i<<":";
cin>>arr[i];
}
}
// This function checks if both arrays are similar or
not
bool equalsArray(int *numbers1,int *numbers2,int length)
{
// If array length is less than 1, return
false
if(length < 1)
{
return false;
}
// If the array length is greater than or
equal to 1
for(int i=0;i<length;i++)
{
/*If value at index i in
the numbers1 array,
*is not equal to value at index i
in the numbers2 array,
*then return false
*/
if( *(numbers1+i) != *(numbers2+i)
)
{
return
false;
}
}
// When this step is reached, it means that
the arrays are similar, so true is returned
return true;
}
main-3-1.cpp contents:
#include "function-3-1.cpp"
int main()
{
int arr_size;
// Reading the sizes of both
arrays
cout<<"Enter the size of both
arrays:";
cin>>arr_size;
// Creating the arrays
int* arr1 = new int[arr_size];
int* arr2 = new int[arr_size];
cout<<"Reading values for first
array"<<endl;
// Reading the values into first
array
readNumbers(arr1,arr_size);
cout<<"\nReading values for second
array"<<endl;
// Reading the values into second
array
readNumbers(arr2,arr_size);
// Storing the result of the function
equalsArray in the variable result
bool result = equalsArray(arr1,arr2,arr_size);
// Printing the result
cout<<"The result is ";
if(result==true)
{
cout<<"true"<<endl;
}
else
{
cout<<"false"<<endl;
}
// Deleting the arrays
delete [] arr1;
delete [] arr2;
return 0;
}
Sample Output:


[ ~/documents/cpp_equals ] [ kandy@Nadimintys-MacBook-Air ] [$]> g++ main-3-1.cpp -o main [kandy@Nadimintys-MacBook-Air] - [~/documents/cpp_equals ] [Tue Aug 27, 16:39] -[$]> ./main Enter the size of both arrays:5 Reading values for first array Enter value to store at index 0:1 [Tue Aug 27, 16:39] Enter value to store at index 1:2 Enter value to store at index 2:3 Enter value to store at index 3:4 Enter value to store at index 4:5 Reading values for second array Enter value to store at index 0:1 Enter value to store at index 1:2 Enter value to store at index 2:3 Enter value to store at index 3:4 Enter value to store at index 4:5 The result is true
/documents/cpp_equals i [ kandy@Nadimintys-MacBook-Air ] [$]> g++ main-3-1.cpp -o main [ kandy@Nadimintys-MacBook-Air] [$]> ./main Enter the size of both arrays:2 Reading values for first array Enter value to store at index 0:3 [Tue Aug 27, 16:40] /documents/cpp_equals [Tue Aug 27, 16:40 Enter value to store at index 1:7 Reading values for second array Enter value to store at index 0:3 Enter value to store at index 1:6 The result is false
Hi there, I'm bit frustrated to see that your website has a same question posted many...
You will be reading in 3 files in the program. One will contain a list of 1000 words in unsorted order. The second file will contain 1000 words in sorted order. The final file will contain 20 words to be searched for. The main program has been written for you. You will be implementing three functions: bool readWords(string array[], int size, string fileName); int linearSearch(string wordToFind, const string words[], int size); int binarySearch(string wordToFind, const string words[], int size); The...
Question 2 In this question, you will read two data files that
include integers into two different arrays – the same way we did in
class (but we are doing to arrays here). Duplicates are ok. 1-
After you read the data into the array (use one function that takes
an int array and a dsize by reference just like we did in class,
and call that from main to fill both arrays). 2- Include a
printArray function so that...
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
in C++ and also each function has its own main function so
please do the main function as well. Previously when i asked the
question the person only did the function and didn't do the main
function so please help me do it.
1-1. Write a function that returns the sum of all elements in an int array. The parameters of the function are the array and the number of elements in the array. The function should return 0 if...
Note: None of these functions should use cout. It is OK to use cout while debugging to check how your function is working, but your final submission should not contain cout in any function but main. Head ==== Name the source file for this section head.cpp. Write a function named "head" which takes an array of integers as an argument, and returns the first element in the array. Write a function named main which outputs the result of testing your...
please
there are some specific instructions on the question so i would
greatly appreciate if they are followed . thank you very much for
your time
This lab covers: arrays functions input exception handling Question 1 The purpose of this question is to write a python program (script) that manipulates arrays using vector arithmetic. You will compute the values of points The ellipse has a major axis whose length is a and a minor axis whose length is b. For...
/** Given an int array, return true if the array contains duplicate values. duplicateInts({3}) -> false duplicateInts({1, 2}) -> false duplicateInts({7, 7}) -> true duplicateInts({1, 2, 3, 4, 5}) -> false duplicateInts({1, 2, 3, 2, 4, 5}) -> true **/ public static boolean duplicateInts(int[] numbers) { //your code here return false; }//end duplicateInts /** Given a String array, return true if the array contains duplicate values. Note: Capital letters count duplicateStrings({"a"}) -> false duplicateStrings({"a", "b", "c", "d"}) -> false duplicateStrings({"a",...
in
java
Part 1 In this section, we relook at the main method by examining passing array as parameters. Often we include options/flags when running programs. On command line, for example, we may do “java MyProgram -a -v". Depending on options, the program may do things differently. For example, "a" may do all things while "-v" display messages verbosely. You can provide options in Eclipse instead of command line: "Run ... Run Configurations ... Arguments". Create a Java class (Main.java)....
Problem 1 1. Consider the following function (K is the size of array A and L is the size of array B) bool func (int A[], int K, int B[], int L, int start) { if (L > K-start) return false; for (int i =0; i < L; i++) { if(A[start+i] != B[i]) return false } return true; } What are the input and output variables to this function. Trace it for the following call: int F[] = {1, 3,...
Qi. Create a java project Question that includes: • A bubble sort method to sort your arrays. Implement the below recursive binary search. • A java main class where you: o Create an array of characters that contains the letters of your first name followed by your last name, without spaces. o Call the sorting method to sort the array o Call binary search method to find the position of the first letter 'a' in your array. // Recursive Binary...