Input and display array of structures Dry Run in C

Input and display array of 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.

Input and display array of structures Program Code

#include <stdio.h>

struct Student {
    int id;
    char name[40];
    float marks;
};

void inputStudents(struct Student s[], int n) {
    for(int i = 0; i < n; i++) {
        printf("Student %d:\n", i+1);
        printf("ID: "); scanf("%d", &s[i].id);
        printf("Name: "); scanf(" %[^\n]", s[i].name);
        printf("Marks: "); scanf("%f", &s[i].marks);
    }
}

void displayStudents(struct Student s[], int n) {
    printf("\n%-5s %-25s %-8s\n", "ID", "Name", "Marks");
    printf("%-5s %-25s %-8s\n", "--", "----", "-----");
    for(int i = 0; i < n; i++) {
        printf("%-5d %-25s %-8.2f\n", s[i].id, s[i].name, s[i].marks);
    }
}

int main() {
    struct Student students[50];
    int n;
    printf("Enter number of students: ");
    scanf("%d", &n);
    inputStudents(students, n);
    displayStudents(students, n);
    return 0;
}

View the complete Structures Arrays programs page.

Program Console Input and display array of structures Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.