Find student with highest marks Dry Run in C

Find student with highest marks 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.

Find student with highest marks Program Code

#include <stdio.h>

struct Student {
    int roll;
    char name[40];
    float totalMarks;
};

int findHighest(struct Student s[], int n) {
    int maxIndex = 0;
    for(int i = 1; i < n; i++) {
        if(s[i].totalMarks > s[maxIndex].totalMarks) {
            maxIndex = i;
        }
    }
    return maxIndex;
}

int main() {
    struct Student students[50];
    int n, i;
    
    printf("Enter number of students: ");
    scanf("%d", &n);
    
    for(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("Total Marks: "); scanf("%f", &students[i].totalMarks);
    }
    
    int topIndex = findHighest(students, n);
    
    printf("\n========== TOPPER ==========\n");
    printf("Roll No: %d\n", students[topIndex].roll);
    printf("Name: %s\n", students[topIndex].name);
    printf("Total Marks: %.2f\n", students[topIndex].totalMarks);
    
    return 0;
}

View the complete Structures Arrays programs page.

Program Console Find student with highest marks Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.