You are required to develop a system to record details of student. This system should be implemented using structure and array. You are required to develop a structure which contains student details such as Student ID, Student Name, Nationality and Gender.
You are also required to create a system which implements the structure which has the following function:
a) Insert new record
In this function, user will able to insert the detail of the student and insert it into array. The Maximum size of array set to 100. If the maximum size reached, the system should inform the user.

b) Delete record
In the delete record function, user able to delete the record by inserting the student ID, the particular record will be removed from the array.
c) Sort record
In the sorting function, user able to sort the record according by selecting student name or student ID
d) Display record
In this function, user will able to display all record in the array to screen.
the program is in c++

Dani AI

Generated

Below is a compact, practical approach for a small C++ student-record program and a short reference implementation. was right — show your code and compiler details when asking for help. 's point about clear titles and using code tags makes it easier for others to find and help. The example below uses a fixed-size array (capacity 100) and keeps a separate count variable; it shows insertion (with duplicate-ID check), deletion (shifting to preserve order), sorting (by ID or name), and display.

#include <iostream>
#include <string>
#include <algorithm>

struct Student {
    int id;
    std::string name;
    std::string nationality;
    char gender; // 'M' or 'F'
};

const int CAP = 100;

bool insertStudent(Student arr[], int &count, const Student &s) {
    if (count >= CAP) return false;
    for (int i = 0; i < count; ++i) if (arr[i].id == s.id) return false; // duplicate
    arr[count++] = s;
    return true;
}

bool deleteById(Student arr[], int &count, int id) {
    for (int i = 0; i < count; ++i) {
        if (arr[i].id == id) {
            for (int j = i; j + 1 < count; ++j) arr[j] = arr[j + 1];
            --count;
            return true;
        }
    }
    return false;
}

// Requires C++11; replace with comparator functions if using older standard
void sortById(Student arr[], int count) {
    std::sort(arr, arr + count, [](const Student &a, const Student &b){ return a.id < b.id; });
}
void sortByName(Student arr[], int count) {
    std::sort(arr, arr + count, [](const Student &a, const Student &b){ return a.name < b.name; });
}

void displayAll(const Student arr[], int count) {
    for (int i = 0; i < count; ++i)
        std::cout << arr[i].id << "\t" << arr[i].name << "\t" << arr[i].nationality << "\t" << arr[i].gender << "\n";
}

Troubleshooting notes: validate numeric input before storing id, use getline for names to accept spaces, and check count bounds to avoid overruns. Deleting by swapping with the last element is faster (O(1)) but changes record order; shifting preserves order (O(n)). For real projects prefer std::vector<Student> for flexibility, but the fixed array approach above matches basic assignment constraints. Post the code you have (wrapped in code tags) and the compiler/version if you want help debugging specific errors.

Recommended Answers

All 5 Replies

You are required to develop a system to record details of student.

No I'm not. I finished school quite a few years back.

Here's something for you to read.

commented: well said. +11

oh sorry!!!

Show use what you have so far and we might be of assistance to you. Don't forget to use code-tags when posting code..

xfreebornx,
Don't you think that it's strange that I call you by a "please ugent help needed". Try to give suitable title for your question, title of the thread must reflect your question.

Don't forget to use code tags.
For example,

[code=cplusplus] .... statements

[/code]

okay tnx guys

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.