My Project
Classes | Functions
stud_rec.cpp File Reference
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string.h>
Include dependency graph for stud_rec.cpp:

Classes

struct  student
 A student class for storing miscellaneous data of a student. More...
 

Functions

int search (struct student st[], string id, int itemcount)
 search() - taking a student class array, a string with the concerned student id and array size as arguments. More...
 
void clean (struct student st[], int index)
 clean() - taking a student class array and the index of the particular student element to be 'erased' as arguments. More...
 
void displaymenu ()
 displaymenu() - no arguments required. More...
 
void add_rec (struct student st[], int &itemcount)
 add_rec() - taking a student class array and the array size as arguments. More...
 
void viewall (struct student st[], int itemcount)
 viewall() - taking a student class array and array size as arguments. More...
 
void delete_rec (struct student st[], int &itemcount)
 delete_rec() - taking a student class array and array size as arguments. More...
 
void update_rec (struct student st[], int itemcount)
 update_rec() - taking a student class array and array size as arguments. More...
 
void showmax (struct student st[], int itemcount)
 showmax() - taking a student class array and array size as arguments. More...
 
void showmin (struct student st[], int itemcount)
 showmin() - taking a student class array and array size as arguments. More...
 
void find (struct student st[], int itemcount)
 find() - taking a student class array and array size as arguments. More...
 
void bubblesort (struct student dataset[], int n)
 bubblesort() - taking a student class array and array size as arguments. More...
 
void average (struct student st[], int itemcount)
 average() - taking a student class array and array size as arguments. More...
 
int main (int argc, char *argv[])
 The main function, where program execution starts.
 

Detailed Description

This Code is taken from http://www.worldbestlearningcenter.com for learning/teaching purpose

Function Documentation

void add_rec ( struct student  st[],
int &  itemcount 
)

add_rec() - taking a student class array and the array size as arguments.

This function adds a new record to the existing student class array

void average ( struct student  st[],
int  itemcount 
)

average() - taking a student class array and array size as arguments.

This function calculates the average marks of a given student id (student id taken from STDIN).

void bubblesort ( struct student  dataset[],
int  n 
)

bubblesort() - taking a student class array and array size as arguments.

A function implementing a simple bubble sort algorithm (O(n^2)) to sort the data with respect to the total marks in ascending order.

void clean ( struct student  st[],
int  index 
)

clean() - taking a student class array and the index of the particular student element to be 'erased' as arguments.

This function changes the values of a particular structure to null functioning similar to erasing data of the structure. Used in the deleterec() for deleting a student record.

void delete_rec ( struct student  st[],
int &  itemcount 
)

delete_rec() - taking a student class array and array size as arguments.

This function deletes a student record from the array of student records by taking input (i.e. student id) from STDIN and searching for the particular student and calling the 'clean' function to erase data.

void displaymenu ( )

displaymenu() - no arguments required.

Function for displaying a menu whenever it is called

void find ( struct student  st[],
int  itemcount 
)

find() - taking a student class array and array size as arguments.

This function is similar to the search() function. The only difference is that this function displays a formatted output containing the student data found at a user-provided (via STDIN) student id while search() only returns the index where the data is present.

int search ( struct student  st[],
string  id,
int  itemcount 
)

search() - taking a student class array, a string with the concerned student id and array size as arguments.

This function searches for a particular student with respect to the student id given as one of the parameters and returns the index where the given student id was found. This function implements linear search for searching the student element. Search time - O(n).

void showmax ( struct student  st[],
int  itemcount 
)

showmax() - taking a student class array and array size as arguments.

This function displays the student id having the maximum total marks in O(n) time.

void showmin ( struct student  st[],
int  itemcount 
)

showmin() - taking a student class array and array size as arguments.

This function works the same as showmax(), except it prints the student id having the minimum total marks.

void update_rec ( struct student  st[],
int  itemcount 
)

update_rec() - taking a student class array and array size as arguments.

This function takes a student id from STDIN and updates the data of the particular student as per the user's demands.

void viewall ( struct student  st[],
int  itemcount 
)

viewall() - taking a student class array and array size as arguments.

This function prints out the complete student array (i.e. all the student data) in STDOUT, including some formatting for presenting the data more neatly.