Compare Two Arrays

Medium Pointer Fundamentals
Solve in Playground →

Problem Statement

Write a C program to check if two arrays are identical using pointers (print 1 if identical, 0 otherwise).

Input Format

First line: n. Second line: n elements of first array. Third line: n elements of second array.

Output Format

Print 1 if identical, else 0.

Constraints

1 <= n <= 100

Sample Input

3
1 2 3
3
1 2 3

Sample Output

1

Explanation

Traverse both arrays simultaneously using pointers and compare each pair of values.

Starter Code

#include <stdio.h>

int main() {
    int n1;
    if (scanf("%d", &n1) == 1) {
        int arr1[100];
        for (int i = 0; i < n1; i++) {
            scanf("%d", &arr1[i]);
        }
        int n2;
        scanf("%d", &n2);
        int arr2[100];
        for (int i = 0; i < n2; i++) {
            scanf("%d", &arr2[i]);
        }
        // Write your code here to compare arrays using pointers
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used