Program Console Vignaankosh.com
Execution Panel
Console is empty.
Compare two arrays using pointer is an interactive C dry run visualizer from the Pointersarrays programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.
This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.
#include <stdio.h>
int compareArrays(int *arr1, int *arr2, int n) {
for(i = 0; i < n; i++) {
if(*(arr1 + i) != *(arr2 + i)) {
return 0; // Not equal
}
}
return 1; // Equal
}
int compareArraysPtr(int *ptr1, int *ptr2, int n) {
int *end = ptr1 + n;
while(ptr1 < end) {
if(*ptr1 != *ptr2) {
return 0;
}
ptr1++;
ptr2++;
}
return 1;
}
int main() {
int arrA[] = {10, 20, 30, 40, 50};
int arrB[] = {10, 20, 30, 40, 50};
int arrC[] = {10, 20, 35, 40, 50};
int n = sizeof(arrA)/sizeof(arrA[0]);
printf("arrA vs arrB: %s\n", compareArrays(arrA, arrB, n) ? "EQUAL" : "NOT EQUAL");
printf("arrA vs arrC: %s\n", compareArrays(arrA, arrC, n) ? "EQUAL" : "NOT EQUAL");
printf("arrA vs arrB (ptr method): %s\n", compareArraysPtr(arrA, arrB, n) ? "EQUAL" : "NOT EQUAL");
return 0;
}