Program Console Vignaankosh.com
Execution Panel
Console is empty.
Update student record 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>
#include <string.h>
struct Student {
int roll;
char name[40];
float marks;
};
int searchByRoll(struct Student s[], int n, int roll) {
for(int i = 0; i < n; i++)
if(s[i].roll == roll) return i;
return -1;
}
void updateStudent(struct Student *s) {
printf("\n--- Updating Record ---\n");
printf("New Name (current: %s): ", s->name);
scanf(" %[^\n]", s->name);
printf("New Marks (current: %.2f): ", s->marks);
scanf("%f", &s->marks);
printf("Record updated successfully!\n");
}
int main() {
struct Student students[50];
int n, roll, index;
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 update: ");
scanf("%d", &roll);
index = searchByRoll(students, n, roll);
if(index != -1) {
printf("\nCurrent Details:\n");
printf("Roll: %d, Name: %s, Marks: %.2f\n",
students[index].roll, students[index].name, students[index].marks);
updateStudent(&students[index]); // Pass pointer to modify
} else {
printf("Student not found!\n");
}
return 0;
}