Structure initialization and member assignment Dry Run in C

Structure initialization and member assignment 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.

Structure initialization and member assignment Program Code

#include <stdio.h>

struct Car {
    char model[30];
    int year;
    float price;
    float mileage;
    char fuelType[10];
};

int main() {
    struct Car car1 = {"Tesla Model 3", 2023, 1850000.00, 18.5, "Electric"};
    struct Car car2;

    sprintf(car2.model, "Honda City");
    car2.year = 2022;
    car2.price = 1250000.00;
    car2.mileage = 17.2;
    sprintf(car2.fuelType, "Petrol");
    
    printf("Car 1: %s (%d) - Rs.%.2f, %.1f km/l, %s\n", 
           car1.model, car1.year, car1.price, car1.mileage, car1.fuelType);
    printf("Car 2: %s (%d) - Rs.%.2f, %.1f km/l, %s\n", 
           car2.model, car2.year, car2.price, car2.mileage, car2.fuelType);
    
    return 0;
}

View the complete Structures programs page.

Program Console Structure initialization and member assignment Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.