Read and print structure members (user input) Dry Run in C

Read and print structure members (user input) 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.

Read and print structure members (user input) Program Code

#include <stdio.h>

struct Employee {
    int id;
    char name[100];
    float salary;
};

int main() {
    struct Employee emp;
    
    printf("Enter Employee ID: ");
    scanf("%d", &emp.id);
    
    printf("Enter Name: ");
    scanf(" %[^\n]", emp.name);  // Reads string with spaces
    
    printf("Enter Salary: ");
    scanf("%f", &emp.salary);
    
    printf("\n--- Employee Details ---\n");
    printf("ID: %d\n", emp.id);
    printf("Name: %s\n", emp.name);
    printf("Salary: Rs.%.2f\n", emp.salary);
    
    return 0;
}

View the complete Structures programs page.

Program Console Read and print structure members (user input) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.