Modify structure using function Dry Run in C

Modify structure using function is an interactive C dry run visualizer from the Struct Functions Pointers 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.

Modify structure using function Program Code

#include <stdio.h>
#include <string.h>

struct Product {
    int code;
    char name[50];
    float price;
};

void applyDiscount(struct Product *p, float discountPercent) {
    float discount = p->price * discountPercent / 100;
    p->price = p->price - discount;
    printf("Discount applied: ₹%.2f\n", discount);
}

int main() {
    struct Product product = {101, "Laptop", 45000.00};
    
    printf("Original Product:\n");
    printf("Code: %d, Name: %s, Price: ₹%.2f\n", 
           product.code, product.name, product.price);
    
    applyDiscount(&product, 10);
    
    printf("\nAfter 10%% discount:\n");
    printf("Code: %d, Name: %s, Price: ₹%.2f\n", 
           product.code, product.name, product.price);
    return 0;
}

View the complete Struct Functions Pointers programs page.

Program Console Modify structure using function Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.