Compare two structures (manual comparison) Dry Run in C

Compare two structures (manual comparison) is an interactive C dry run visualizer from the Structures 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.

Compare two structures (manual comparison) Program Code

#include <stdio.h>
#include <string.h>

struct Rectangle {
    int length;
    int breadth;
    char color[20];
};

int compareRectangles(struct Rectangle r1, struct Rectangle r2) {
    if(r1.length == r2.length && 
       r1.breadth == r2.breadth && 
       strcmp(r1.color, r2.color) == 0) {
        return 1;  // Equal
    }
    return 0;  // Not equal
}

int main() {
    struct Rectangle rect1 = {10, 5, "Red"};
    struct Rectangle rect2 = {10, 5, "Red"};
    struct Rectangle rect3 = {15, 8, "Blue"};
    
    if(compareRectangles(rect1, rect2)) {
        printf("Rectangle 1 and 2 are EQUAL\n");
    } else {
        printf("Rectangle 1 and 2 are NOT equal\n");
    }
    
    if(compareRectangles(rect1, rect3)) {
        printf("Rectangle 1 and 3 are EQUAL\n");
    } else {
        printf("Rectangle 1 and 3 are NOT equal\n");
    }
    
    return 0;
}

View the complete Structures programs page.

Program Console Compare two structures (manual comparison) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.