We have two arrays A and B, each of 10 integers. Write a function that tests if every element of array A is equal to its corresponding element in array B. In other words, the function must check if A[0]
is equal to B[0]
, A[1]
is equal to B[1]
, and so forth. The function is to return true if all elements are equal and false if at least one element is not equal.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
/* run this program using the console pauser or add
your own getch, system("pause") or input loop */
bool array(int ptr1[], int ptr2[]);
int main(int argc, char *argv[]) {
int array1[] = {11, 33, 34, 25, 16, 2, 24, 57, 86, 66};
int array2[] = {11, 33, 34, 25, 16, 2, 24, 57, 86, 66};
int i;
printf("Array A\t\tArray B\n");
for(i = 0; i < 10; i++)
printf("%d\t\t%d\n", array1[i], array2[i]);
printf("\nResult of comparision: \n");
bool result = array (array1, array2);
if(result == 1)
printf("false\n");
else
printf("false\n");
getch();
return 0;
}
The errors that I get are:
main.c(.text+0xfa): undefined 'array' [Error] Id returned 1 exit status recipe for target '"Problem' failed