Student Database

Medium File Handling
Solve in Playground →

Problem Statement

Write a C program to write a student structure record into a binary file using fwrite() and read it back using fread().

Input Format

Roll number (int), name (string), and marks (float).

Output Format

Print the retrieved record in format 'Roll: X, Name: Y, Marks: Z'.

Constraints

1 <= Roll <= 1000, 0 <= Marks <= 100

Sample Input

101 John 88.5

Sample Output

Roll: 101, Name: John, Marks: 88.50

Explanation

Uses binary I/O functions fwrite and fread to persist and load structures.

Starter Code

#include <stdio.h>

struct Student {
    int roll;
    char name[51];
    float marks;
};

int main() {
    struct Student s;
    if (scanf("%d %50s %f", &s.roll, s.name, &s.marks) == 3) {
        // Write your code here
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used