Employee record system (salary calculation) Dry Run in C

Employee record system (salary calculation) 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.

Employee record system (salary calculation) Program Code

#include <stdio.h>

struct Employee {
    int empId;
    char name[40];
    float basicSalary;
    float hra;      // House Rent Allowance
    float da;       // Dearness Allowance
    float grossSalary;
};

void calculateGrossSalary(struct Employee *e) {
    // HRA = 20% of basic, DA = 50% of basic
    e->hra = e->basicSalary * 0.20;
    e->da = e->basicSalary * 0.50;
    e->grossSalary = e->basicSalary + e->hra + e->da;
}

int main() {
    struct Employee employees[50];
    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("Basic Salary: "); scanf("%f", &employees[i].basicSalary);
        calculateGrossSalary(&employees[i]);
    }
    
    printf("\n========== SALARY REPORT ==========\n");
    printf("%-6s %-20s %-10s %-10s %-10s\n", "ID", "Name", "Basic", "HRA", "DA", "Gross");
    for(int i = 0; i < n; i++) {
        printf("%-6d %-20s %-10.2f %-10.2f %-10.2f %-10.2f\n", 
               employees[i].empId, employees[i].name, 
               employees[i].basicSalary, employees[i].hra, 
               employees[i].da, employees[i].grossSalary);
    }
    
    return 0;
}

View the complete Structures Arrays programs page.

Program Console Employee record system (salary calculation) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.