Salary Slip (Basic + Allowances - Deductions) Dry Run in C

Salary Slip (Basic + Allowances - Deductions) is an interactive C dry run visualizer from the Input Output 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.

Salary Slip (Basic + Allowances - Deductions) Program Code

#include <stdio.h>
int main() {
    // Input
    float basic, hra, da, ta, other_allowances;
    float pf, tax, other_deductions;
    float gross_salary, total_deductions, net_salary;
    
    // Taking basic salary input
    printf("Enter Basic Salary: ");
    scanf("%f", &basic);
    
    // Calculating Allowances (percentage of basic)
    hra = basic * 0.20;  // House Rent Allowance (20%)
    da = basic * 0.15;   // Dearness Allowance (15%)
    ta = basic * 0.10;   // Travel Allowance (10%)
    other_allowances = basic * 0.05;  // Other Allowances (5%)
    
    // Calculating Deductions
    pf = basic * 0.12;   // Provident Fund (12%)
    tax = basic * 0.10;  // Income Tax (10%)
    other_deductions = basic * 0.03;  // Other Deductions (3%)
    
    // Calculations
    gross_salary = basic + hra + da + ta + other_allowances;
    total_deductions = pf + tax + other_deductions;
    net_salary = gross_salary - total_deductions;
    
    // Display Salary Slip
    printf("\n========== SALARY SLIP ==========\n");
    printf("-----------------------------------\n");
    printf("EARNINGS                AMOUNT\n");
    printf("-----------------------------------\n");
    printf("Basic Salary           %.2f\n", basic);
    printf("HRA (20%%)              %.2f\n", hra);
    printf("DA (15%%)               %.2f\n", da);
    printf("TA (10%%)               %.2f\n", ta);
    printf("Other Allowances (5%%)  %.2f\n", other_allowances);
    printf("-----------------------------------\n");
    printf("GROSS SALARY           %.2f\n", gross_salary);
    printf("-----------------------------------\n\n");
    
    printf("DEDUCTIONS              AMOUNT\n");
    printf("-----------------------------------\n");
    printf("PF (12%%)               %.2f\n", pf);
    printf("Income Tax (10%%)       %.2f\n", tax);
    printf("Other Deductions (3%%)  %.2f\n", other_deductions);
    printf("-----------------------------------\n");
    printf("TOTAL DEDUCTIONS       %.2f\n", total_deductions);
    printf("-----------------------------------\n\n");
    
    printf("NET SALARY             %.2f\n", net_salary);
    printf("===================================\n");
    
    return 0;
}

View the complete Input Output programs page.

Program Console Salary Slip (Basic + Allowances - Deductions) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.