Program Console Vignaankosh.com
Execution Panel
Console is empty.
Menu-driven program using function pointers is an interactive C dry run visualizer from the Pointersfunctions 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 <stdlib.h>
// Function declarations
void addRecord();
void viewRecords();
void searchRecord();
void deleteRecord();
void exitProgram();
// Function pointer type for menu actions
typedef void (*MenuAction)();
int main() {
int i;
// Array of function pointers for menu options
MenuAction menu[] = {addRecord, viewRecords, searchRecord, deleteRecord, exitProgram};
char *menuOptions[] = {
"Add Record",
"View Records",
"Search Record",
"Delete Record",
"Exit"
};
int choice;
printf("=== Student Record Management System ===\n\n");
do {
// Display menu
printf("\n--- Menu ---\n");
for(i = 0; i < 5; i++) {
printf("%d. %s\n", i+1, menuOptions[i]);
}
printf("Enter choice: ");
scanf("%d", &choice);
if(choice >= 1 && choice <= 5) {
printf("\n");
menu[choice-1](); // Call the selected function
} else {
printf("Invalid choice! Please try again.\n");
}
} while(choice != 5);
return 0;
}
// Menu function implementations
void addRecord() {
static int id = 1;
char name[50];
int age;
printf("--- Add New Record ---\n");
printf("Enter name: ");
scanf("%s", name);
printf("Enter age: ");
scanf("%d", &age);
printf("Record added! (ID: %d, Name: %s, Age: %d)\n", id++, name, age);
}
void viewRecords() {
printf("--- View All Records ---\n");
printf("Would display all records here...\n");
printf("(In a real program, this would show stored data)\n");
}
void searchRecord() {
char term[50];
printf("--- Search Record ---\n");
printf("Enter search term: ");
scanf("%s", term);
printf("Searching for '%s'... (Would display results)\n", term);
}
void deleteRecord() {
int id;
printf("--- Delete Record ---\n");
printf("Enter ID to delete: ");
scanf("%d", &id);
printf("Record with ID %d deleted! (Would actually delete)\n", id);
}
void exitProgram() {
printf("Exiting program. Goodbye!\n");
}