Structure Search

Medium Structures & Unions
Solve in Playground →

Problem Statement

Write a C program to search for a student by roll number in an array of structures and print their name.

Input Format

First line: N and Target Roll. Next N lines: Roll number, name, and marks.

Output Format

Print the student's name if found, otherwise 'Not Found'.

Constraints

1 <= N <= 100

Sample Input

3 102
101 John 85.0
102 Alice 92.0
103 Bob 78.5

Sample Output

Alice

Explanation

Roll 102 matches Alice in the student database.

Starter Code

#include <stdio.h>

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

int main() {
    int n, target;
    if (scanf("%d %d", &n, &target) == 2) {
        struct Student s[n];
        for (int i = 0; i < n; i++) {
            scanf("%d %50s %f", &s[i].roll, s[i].name, &s[i].marks);
        }
        // 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