I want to compare two different arrays which are both int
. One array is static and contains numbers from 1 to 10 and second arrays asks user to enter ten different numbers and the program checks which elements from both arrays are equal.
#include <stdio.h>
int main(void) {
int array1[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int array2[10];
int i;
for (i = 0; i < 11; i++) {
printf("Enter numbers: ");
scanf("%d", &array2);
}
for (i = 0; i < 11; i++) {
if (array1[i] != array2[i]) {
printf("Not equal \n");
} else {
printf("They are equal. \n");
}
}
}
The program always say not equal even if I enter a number that is equal to a number stored in first array.