Program Console Vignaankosh.com
Execution Panel
Console is empty.
Menu-driven structure program using functions 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 Student {
int roll;
char name[50];
float marks;
};
void addStudent(struct Student students[], int *count) {
printf("\n--- Add Student ---\n");
printf("Enter Roll No: ");
scanf("%d", &students[*count].roll);
printf("Enter Name: ");
scanf(" %[^\n]", students[*count].name);
printf("Enter Marks: ");
scanf("%f", &students[*count].marks);
(*count)++;
printf("Student added successfully!\n");
}
void displayAll(struct Student students[], int count) {
if(count == 0) {
printf("\nNo students to display!\n");
return;
}
printf("\n--- All Students ---\n");
printf("%-10s %-20s %-10s\n", "Roll", "Name", "Marks");
printf("----------------------------------------\n");
for(int i = 0; i < count; i++) {
printf("%-10d %-20s %-10.2f\n",
students[i].roll, students[i].name, students[i].marks);
}
}
void searchStudent(struct Student students[], int count) {
if(count == 0) {
printf("\nNo students to search!\n");
return;
}
int roll, found = 0;
printf("\n--- Search Student ---\n");
printf("Enter Roll No: ");
scanf("%d", &roll);
for(int i = 0; i < count; i++) {
if(students[i].roll == roll) {
printf("\nStudent Found:\n");
printf("Roll: %d\n", students[i].roll);
printf("Name: %s\n", students[i].name);
printf("Marks: %.2f\n", students[i].marks);
found = 1;
break;
}
}
if(!found) printf("Student not found!\n");
}
void updateStudent(struct Student students[], int count) {
if(count == 0) {
printf("\nNo students to update!\n");
return;
}
int roll, found = 0;
printf("\n--- Update Student ---\n");
printf("Enter Roll No: ");
scanf("%d", &roll);
for(int i = 0; i < count; i++) {
if(students[i].roll == roll) {
printf("Enter New Name: ");
scanf(" %[^\n]", students[i].name);
printf("Enter New Marks: ");
scanf("%f", &students[i].marks);
printf("Student updated successfully!\n");
found = 1;
break;
}
}
if(!found) printf("Student not found!\n");
}
int main() {
struct Student students[100];
int count = 0;
int choice;
do {
printf("\n========== STUDENT MANAGEMENT SYSTEM ==========\n");
printf("1. Add Student\n");
printf("2. Display All Students\n");
printf("3. Search Student\n");
printf("4. Update Student\n");
printf("5. Exit\n");
printf("===============================================\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch(choice) {
case 1: addStudent(students, &count); break;
case 2: displayAll(students, count); break;
case 3: searchStudent(students, count); break;
case 4: updateStudent(students, count); break;
case 5: printf("Exiting... Thank you!\n"); break;
default: printf("Invalid choice! Try again.\n");
}
} while(choice != 5);
return 0;
}