Program Console Vignaankosh.com
Execution Panel
Console is empty.
Pass structure pointer to 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.
#include <stdio.h>
#include <string.h>
struct Book {
int id;
char title[100];
char author[50];
float price;
};
void inputBook(struct Book *b) {
printf("Enter Book ID: ");
scanf("%d", &b->id);
printf("Enter Title: ");
scanf(" %[^\n]", b->title);
printf("Enter Author: ");
scanf(" %[^\n]", b->author);
printf("Enter Price: ");
scanf("%f", &b->price);
}
void displayBook(struct Book *b) {
printf("\n--- Book Details ---\n");
printf("ID: %d\n", b->id);
printf("Title: %s\n", b->title);
printf("Author: %s\n", b->author);
printf("Price: ₹%.2f\n", b->price);
}
void applyDiscount(struct Book *b, float percent) {
float discount = b->price * percent / 100;
b->price -= discount;
printf("Discount applied: %.1f%% (₹%.2f)\n", percent, discount);
}
int main() {
struct Book myBook;
printf("Enter Book Information:\n");
inputBook(&myBook);
displayBook(&myBook);
applyDiscount(&myBook, 15);
printf("Price after discount: ₹%.2f\n", myBook.price);
return 0;
}