Program Console Vignaankosh.com
Execution Panel
Console is empty.
Inventory system (product details) 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.
#include <stdio.h>
struct Product {
int prodId;
char name[50];
int stock;
float price;
float totalValue;
};
void calculateTotalValue(struct Product p[], int n) {
for(int i = 0; i < n; i++) {
p[i].totalValue = p[i].stock * p[i].price;
}
}
void displayInventory(struct Product p[], int n) {
printf("\n%-8s %-25s %-8s %-10s %-12s\n",
"Prod ID", "Product Name", "Stock", "Price", "Total Value");
for(int i = 0; i < n; i++) {
printf("%-8d %-25s %-8d ₹%-9.2f ₹%-11.2f\n",
p[i].prodId, p[i].name, p[i].stock, p[i].price, p[i].totalValue);
}
}
float inventoryWorth(struct Product p[], int n) {
float total = 0;
for(int i = 0; i < n; i++) {
total += p[i].totalValue;
}
return total;
}
int main() {
struct Product inventory[100];
int n;
printf("Enter number of products: ");
scanf("%d", &n);
for(int i = 0; i < n; i++) {
printf("\nProduct %d:\n", i+1);
printf("ID: "); scanf("%d", &inventory[i].prodId);
printf("Name: "); scanf(" %[^\n]", inventory[i].name);
printf("Stock: "); scanf("%d", &inventory[i].stock);
printf("Price: "); scanf("%f", &inventory[i].price);
}
calculateTotalValue(inventory, n);
displayInventory(inventory, n);
printf("\nTotal Inventory Worth: ₹%.2f\n", inventoryWorth(inventory, n));
return 0;
}