Compare Two Arrays In C Programming

Let’s have a look at C Program to Compare Two Arrays. The output of the program will be “They are equal” if both the arrays are equal otherwise it will say “They are not equal”.

C Program To Compare Two Arrays

#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<10;i++) { //fixed the range here

            printf("Enter numbers: ");
            scanf("%d", &array2[i]); //fixed the indexing

    for (i=0;i<10;i++) { //fixed the range here

            if (array1[i] != array2[i]) {

                    printf("They are equal \n");
            else {
                    printf("They are not equal. \n");
    } }


Leave a Reply

Your email address will not be published. Required fields are marked *

Shopping cart