Structure array with nested structures Dry Run in C

Structure array with nested structures is an interactive C dry run visualizer from the Structures Arrays 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.

Structure array with nested structures Program Code

#include <stdio.h>

struct Address {
    char street[100];
    char city[40];
    int pincode;
};

struct Employee {
    int empId;
    char name[50];
    struct Address addr;  // Nested structure
    float salary;
};

int main() {
    struct Employee employees[30];
    int n;
    
    printf("Enter number of employees: ");
    scanf("%d", &n);
    
    for(int i = 0; i < n; i++) {
        printf("\n--- Employee %d ---\n", i+1);
        printf("ID: "); scanf("%d", &employees[i].empId);
        printf("Name: "); scanf(" %[^\n]", employees[i].name);
        printf("Street: "); scanf(" %[^\n]", employees[i].addr.street);
        printf("City: "); scanf(" %[^\n]", employees[i].addr.city);
        printf("Pincode: "); scanf("%d", &employees[i].addr.pincode);
        printf("Salary: "); scanf("%f", &employees[i].salary);
    }
    
    printf("\n========== EMPLOYEE DIRECTORY ==========\n");
    for(int i = 0; i < n; i++) {
        printf("\nEmployee ID: %d\n", employees[i].empId);
        printf("Name: %s\n", employees[i].name);
        printf("Address: %s, %s - %d\n", 
               employees[i].addr.street, 
               employees[i].addr.city, 
               employees[i].addr.pincode);
        printf("Salary: ₹%.2f\n", employees[i].salary);
        printf("-----------------------------------\n");
    }
    
    return 0;
}

View the complete Structures Arrays programs page.

Program Console Structure array with nested structures Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.