You are here:

C++/Student Detail Recording System


i am required to develop a system to record details of student.
This system should be implemented using structure and array. i am required to develop a structure which contains student details such as Student ID, Student Name, Nationality and Gender.

1st-i have to insert new record- max 100
2nd-delete record
3rd-sort record
4th-display record

my question is how to use a structure and array in this program. i haven't done my coding. but i wish to know the steps. i have learned this but not in coding. please show me the way so that i can improve. can i know what's the function of file/io and pointer? thanks

a. First define a structure to hold the student information, like this:

#include <string>

struct student_information
       int id ;
       std::string name ;
       std::string nationality ;

       enum gender_t { MALE, FEMALE };
       gender_t gender ;

b. Then define an array to hold a information about up to 100 students:

enum { MAX_STUDENTS = 100 } ;

student_information student_info_array[ MAX_STUDENTS ] ;

c. Define a variable to hold the actual number of students - this is initialized to zero and can go up to a maximum of MAX_STUDENTS

int number_of_students = 0 ;

d. To insert a new record:
    1. accept id, name, nationality and gender from std input.
    2. store it in the student_information at student_info_array[ number_of_students ] ;
    3. increment number_of_students

e. To delete a record
    1. search in the array to determine position (say pos) of record to be deleted
    2. move all the elements at position greater than pos to the left by one position
         for( int i = pos + 1 ; i < number_of_students ; ++i )
         student_info_array[ i - 1 ] = student_info_array[ i ] ;
    3. decrement number_of_students

f. To print all records, iterate through the entire array, printing elements one by one
         for( int i = 0 ; i < number_of_students ; ++i )
         display the members of student_info_array[ i ] ;

Implement this much first, one step at a time, and make sure that it is working correctly.
We can look at how to sort and file i/o after that.  


All Answers

Answers by Expert:

Ask Experts




my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++11. i would not answer questions about gui and web programming.


about 15 years or so

post graduate engineer

©2017 All rights reserved.