Program Console Vignaankosh.com
Execution Panel
Console is empty.
Enhanced Enum Calculator with Input Validation is an interactive C dry run visualizer from the Switch 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>
enum Menu {ADD = 1, SUB, MUL, DIV};
int main() {
float a, b;
int choice;
printf("=== ENUM CALCULATOR ===\n");
printf("Enter first number: ");
scanf("%f", &a);
printf("Enter second number: ");
scanf("%f", &b);
printf("\nMenu:\n");
printf("%d. ADDITION\n", ADD);
printf("%d. SUBTRACTION\n", SUB);
printf("%d. MULTIPLICATION\n", MUL);
printf("%d. DIVISION\n", DIV);
printf("Enter your choice: ");
scanf("%d", &choice);
switch(choice) {
case ADD:
printf("\n%.2f + %.2f = %.2f", a, b, a + b);
break;
case SUB:
printf("\n%.2f - %.2f = %.2f", a, b, a - b);
break;
case MUL:
printf("\n%.2f × %.2f = %.2f", a, b, a * b);
break;
case DIV:
if(b != 0) {
printf("\n%.2f ÷ %.2f = %.2f", a, b, a / b);
} else {
printf("\nError: Division by zero!");
}
break;
default:
printf("\nInvalid choice! Please select 1-4");
}
printf("\n");
return 0;
}