Program Console Vignaankosh.com
Execution Panel
Console is empty.
Delete a student record (shifting elements) 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 Student {
int roll;
char name[40];
float marks;
};
int deleteStudent(struct Student s[], int *n, int targetRoll) {
int index = -1;
for(int i = 0; i < *n; i++) {
if(s[i].roll == targetRoll) {
index = i;
break;
}
}
if(index == -1) return 0; // Not found
// Shift elements left to overwrite the deleted record
for(int i = index; i < *n - 1; i++) {
s[i] = s[i + 1];
}
(*n)--; // Decrease count
return 1; // Successfully deleted
}
int main() {
struct Student students[50];
int n, roll;
printf("Enter number of students: ");
scanf("%d", &n);
for(int i = 0; i < n; i++) {
printf("\nStudent %d:\n", i+1);
printf("Roll: "); scanf("%d", &students[i].roll);
printf("Name: "); scanf(" %[^\n]", students[i].name);
printf("Marks: "); scanf("%f", &students[i].marks);
}
printf("\nEnter Roll Number to delete: ");
scanf("%d", &roll);
if(deleteStudent(students, &n, roll)) {
printf("\nRecord deleted successfully!\n");
printf("\nRemaining Students (%d):\n", n);
for(int i = 0; i < n; i++) {
printf("%d. Roll: %d, Name: %s, Marks: %.2f\n",
i+1, students[i].roll, students[i].name, students[i].marks);
}
} else {
printf("Student not found!\n");
}
return 0;
}