Structure Search

Medium Structures
Solve in Playground →

Problem Statement

Write a C++ program that reads an array of N `Student` structures and searches for a student by roll number.

Input Format

Number of students N, followed by N records (Roll, Name, Marks), followed by target roll number to search.

Output Format

Print student name and marks if found, otherwise 'Not Found'.

Constraints

1 <= N <= 50

Sample Input

3
101 John 85.5
102 Alice 96.0
103 Bob 90.0
102

Sample Output

Alice: 96.00

Explanation

Iterates through an array of structures to match search queries.

Starter Code

#include <iostream>
#include <vector>
#include <string>
#include <iomanip>

struct Student {
    int roll;
    std::string name;
    float marks;
};

int main() {
    int n;
    if (std::cin >> n) {
        std::vector<Student> students(n);
        for (int i = 0; i < n; i++) {
            std::cin >> students[i].roll >> students[i].name >> students[i].marks;
        }
        int target;
        std::cin >> target;
        // Write your code here to search and print
    }
    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