Program Console Vignaankosh.com
Execution Panel
Console is empty.
Search student by ID (Linear Search) 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 searchByRoll(struct Student s[], int n, int targetRoll) {
for(int i = 0; i < n; i++) {
if(s[i].roll == targetRoll) {
return i; // Found at index i
}
}
return -1; // Not found
}
int main() {
struct Student students[50];
int n, searchRoll;
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 search: ");
scanf("%d", &searchRoll);
int index = searchByRoll(students, n, searchRoll);
if(index != -1) {
printf("\n========== STUDENT FOUND ==========\n");
printf("Roll No: %d\n", students[index].roll);
printf("Name: %s\n", students[index].name);
printf("Marks: %.2f\n", students[index].marks);
} else {
printf("\nStudent with Roll No %d NOT FOUND!\n", searchRoll);
}
return 0;
}