Student Record C++(cpp) Source Code Windows Console Application – Genuine Coder

Student Record C++(cpp) Source Code Windows Console Application

Let’s have a look at C++ source code for a student record program developed for windows console mode. You can test this code using Microsoft visual C++ compiler without any issues. I believe this sample code will help you to understand some of the basic C++ functions.
This is a menu driven program. You can add a student, get a student’s mark by entering his roll number, get a student’s details or print a table of all student’s details. This program creates a “student.dat” file at the current directory (The path at which the executable located) to save details that you have entered. During the next execution of the program the data present in the file is taken in to the memory. For deleting all existing data, you can use ’99’ command in main menu. It just delete existing file and create a new one having no records, simply a blank file.

……………………………………………………………………………………………………………………………………….

#include<iostream>
#include<windows.h> //for_sleep()_function
#include<iomanip> // for_setwidth_function
#include<fstream>
#include<process.h> //For_exit(0)
#include<conio.h>  //for_getch()
#include<string.h>
#include<stdio.h> //for_gets()
  int k=0, sys, str,high=60;   //For_student_object_handling
  using namespace std;
class person
{
protected:

       char sex;

       int age;

       int count;

       char name[50];

public:

       int length;

       void readperson()

       {

              system("CLS");

           cout<<"tt************************************************";

           cout<<"nttttADD A NEW STUDENT ";

           cout<<"ntt************************************************";

              cout<<"nn Good name please (Don't Use space; use '_') :";

              cin>>name;

              cout<<"n Please Enter your age :";

              cin>>age;

              cout<<"n Sex ? (M/F) :";

              cin>>sex;

       }

};

class student:public person     //This_class_student_is_inherited_from_class_person.

{

protected:

       int roll;

       int avmark;

public:

  void readstudent()

  {

         cout<<"nn Enter your Roll Number :";cin>>roll;

         cout<<"n Enter Your Average Mark( Out of hundred ) :";cin>>avmark;

  }

  int getroll()           

  {

         return(roll);

  }

  void getdetails()

  {

         cout<<"nn Name  :"<<name;

         cout<<"n Sex   :"<<sex;

         cout<<"n Age   :"<<age;

         cout<<"n Roll  :"<<roll;

         cout<<"n Mark  :"<<avmark;

  }

  void GetDetailsTable() //For_making_table_arrangement_of_students;

  {    high--;

          if(str<=7)          //For_maintaining_the_exact_form; One_extra_t_is_used_after_name;

              cout<<"ntt"<<name<<"tt"<<sex<<"t"<<age<<"t"<<roll<<"t"<<avmark<<"n";

          else

           cout<<"ntt"<<name<<"t"<<sex<<"t"<<age<<"t"<<roll<<"t"<<avmark<<"n";

 }

  int getmark()

  {

         return(avmark);

  }

  void prtname()

  {

         cout<<name;

  }

  char GetSex()

  {

         return sex;

  }


}stu[61];// Class_Defnition_completed


void main()        //Beggining_main_function_HERE


{  

       void SortBySex();

       void SortItOnMark();

       void SortItOnRoll() ;

       ofstream fout;

       ifstream fin;

       start:                    //For_returning_into_main_menu

       fin.close();

       fout.close();

       fin.open("student.dat", ios::app|ios::binary|ios::in);

       int num=0; //Making_input_buffer_zero_after_function_returning_through_start:

       while(fin) // Taking Student details into memory

       {     

           fin.read((char *)&stu[num], sizeof(stu[num]));

              ++num;

       }

                    //File_input_completed !

       sys=num-1;

       int p1=100, p2=50;

       system("color f1");

       int k, Ru, rank(0), rankm(0);

       system("CLS");

       cout<<"tt************************************************";

       cout<<setw(62)<<"MAIN MENU";

       cout<<"ntt************************************************";

       cout<<"nnn 1.Student Details"<<"n 2.Best Student"<<"n 3.Get Mark"<<"n 4.Add a new student"<<"n 5.View all students"<<"n 6.Exittttttttt99.Reset all!!!"<<"nnn Enter your selection :";

       cin>>k;

       switch(k)

       {  //switch_starts

       case 1:system("cls");

              int flag;

              flag=0;

           cout<<"tt************************************************";

           cout<<"nttttSTUDENT DETAILS";

           cout<<"ntt************************************************";

              cout<<"nnEnter Roll Number :";

                 cin>>Ru;

                 for (int i=0; i<60;++i)

                 {

                 if (stu[i].getroll()==Ru)

                           {

                                  flag=1;

                                  stu[i].getdetails();

                         }

                 }

                     if (!flag)

                     cout<<"nnnnSorry...I cannot find a student with this roll number !";

                  cout<<"nnnnnPress Any key.............";

                     if(_getch())

                      goto start;

                    

       case 2:system("cls");

              cout<<"tt************************************************";

           cout<<"nttttTHE BEST STUDENT ";

           cout<<"ntt************************************************";

              cout<<"nn Best Student is :";

                 for (int i=0; i<60; ++i)

                 {

                                             

                        if (stu[i].getmark()>rankm)

                        {

                              rankm=stu[i].getmark();

                              rank=i;

                        }

                 }

                 stu[rank].getdetails();

                 cout<<"nnnnnPress Any key.............";

                     if(_getch())

                      goto start;

       case 3:system("cls");

              flag=1;

           cout<<"tt************************************************";

           cout<<"nttttGET THE MARK ";

           cout<<"ntt************************************************";

              cout<<"nnnPlease Enter Roll Number :";

              cin>>Ru;

                 for (int i=0; i<60;++i)

                 {

                        if (stu[i].getroll()==Ru)

                           {

                                  flag=0;

                                  cout<<"nnn Mark of ";stu[i].prtname();cout<<" is "<<stu[i].getmark();

                         }

                 }

                 if(flag)

                         cout<<"nnttSorry....No Such students; Try again !";               

           if(_getch())   //wait_for_any_input_via_keyboard

                  goto start;

              break;

       case 4:               //Add_student_menu

                 stu[k].readperson();

                 stu[k].readstudent();

                     fout.open("student.dat", ios::out|ios::binary|ios::app);

                     fout.write((char*)&stu[k], sizeof(student));

                     cout<<"nnntttFile saving accomplsihed !Please Restart this program ";

                  fout.close();

                     fin.close();

                     cout<<"nnnnnn";

                     Sleep(2500);

                     goto start;

      

                     break;

       case 5:   // View_all_students_table

              system("CLS");

              int count, selection;

              char answer;

              answer='n';

              count=0;

              cout<<sys;

              cout<<"tt************************************************";

           cout<<"nttNamettSextAgetRolltMarkn";

           cout<<"tt************************************************";

              while (count<sys)

              {

                     stu[count].GetDetailsTable();

               count++;

              }

              cout<<"nnttDo you want to sort it now ? (y/n) :";

              cin>>answer;

              if(answer=='y'||answer=='Y')

      {     

                     cout<<"n Sort By :nt1. Marknttt2.Rollnttttt3.By Sexnn";

                  cout<<"Enter :";

                     cin>>selection;

                switch(selection)

                  {

                 case 1: SortItOnMark();break;

                    case 2: SortItOnRoll();break;

                    case 3: SortBySex();break;

                  default :cout<<"nBad Input !";

                  }

              }

              else

                     goto start;

           cout<<"nnnn";system("pause");

              goto start;

       case 6 : //Exit_Function

              system("CLS");

              fin.close();

              fout.close();

              cout<<"nnnttt BYE !!!!!!!!!!!!!!!!!!!!!";

              Sleep(1000);   //wait_1_second_before_exiting

              exit(0);

              break;


case 99 :

               // File-reset_option_begins

              char ans;

              system("CLS");

              cout<<" You have choosen to delete all the user data from this program !.nnCaution :You cannot back up your data !nnFor further reference make a copy of file (student.dat) from source folder !";

              cout<<"nn Are you sure want to erase all (y/n)? :";

              cin>>ans;

              if (ans=='y'||ans=='Y')

              {

        ofstream fout;

              fout.open("student.dat", ios::out,ios::binary);

              cout<<"nnna"<<"taa Task accomplished Successfully !";

              }

              else

                     cout<<"nn"<<"atTask aborted, Now returning to main menu";

                  Sleep(2500);

                     goto start;

              //File_reset_accomplished 


       default : system("CLS");

                    cout<<"annntttBad input Recieved ! Try Again";

                    Sleep(1000);

                       goto start;

                       break;


} //switch ended

        

return;


} // Main()_over


void SortItOnRoll()   //Student_Details_table_sorted_on_mark

{  

       high=60;

    int car=sys;

       cout<<"tt************************************************";

       cout<<"nttNamettSextAgetRolltMarkn";

       cout<<"tt************************************************n";

       int first=0, place;

       while(car)

       {first=0;

       for(int t=0; t<(high); ++t)

       {

              if(first<=stu[t].getroll())

              {

                     first=stu[t].getroll();

                  place=t;

              }

       }

       stu[place].GetDetailsTable();

       stu[place]=stu[high];

       car--;

   }

}          //Function_completed

void SortItOnMark()   //Student_Details_table_sorted_on_mark

{  

       high=60;

    int car=sys;

       cout<<"tt************************************************";

       cout<<"nttNamettSextAgetRolltMarkn";

       cout<<"tt************************************************n";

       int first=0, place;

       while(car)

       {first=0;

       for(int t=0; t<(high); ++t)

       {

              if(first<=stu[t].getmark())

              {

                     first=stu[t].getmark();

                  place=t;

              }

       }

       stu[place].GetDetailsTable();

       stu[place]=stu[high];

       car--;

   }

}          //Function_completed


void SortBySex()   //Student_Details_table_sorted_on_Sex

{  

       high=60;

    int car=sys;

       cout<<"tt************************************************";

       cout<<"nttNamettSextAgetRolltMarkn";

       cout<<"tt************************************************n";

       for(int t=0; t<sys; ++t)

       {

              if(stu[t].GetSex()=='f'||stu[t].GetSex()=='F')

              {

                     stu[t].GetDetailsTable();

              }

              else continue;

       }

       cout<<endl;

       for(int t=0; t<sys; ++t)

       {

              if(stu[t].GetSex()=='m'||stu[t].GetSex()=='M')

              {

                     stu[t].GetDetailsTable();

              }

              else continue;

       }


}          //Function_completed
………………………………………………………………………………………………………………………………………………

Download Source Now

Screenshots

MENU
Student Table

Suggested Read : C++ Library Management Program with Source Code

Comments

49 responses to “Student Record C++(cpp) Source Code Windows Console Application”

  1. … [Trackback]

    […] Find More Information here to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  2. … [Trackback]

    […] Read More on to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  3. … [Trackback]

    […] Find More to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  4. … [Trackback]

    […] Read More Info here to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  5. … [Trackback]

    […] Find More here on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  6. … [Trackback]

    […] Find More on to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  7. … [Trackback]

    […] Here you can find 1154 additional Info on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  8. … [Trackback]

    […] Read More on on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  9. … [Trackback]

    […] Here you can find 80664 additional Info on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  10. … [Trackback]

    […] Information on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  11. … [Trackback]

    […] Read More Information here on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  12. … [Trackback]

    […] Information on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  13. … [Trackback]

    […] There you can find 9252 additional Information to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  14. … [Trackback]

    […] Read More to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  15. … [Trackback]

    […] Information to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  16. … [Trackback]

    […] Find More on on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  17. … [Trackback]

    […] Read More Information here to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  18. … [Trackback]

    […] There you can find 28961 more Info on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  19. … [Trackback]

    […] Read More on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  20. … [Trackback]

    […] Read More on to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  21. … [Trackback]

    […] Find More here to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  22. … [Trackback]

    […] Find More here on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  23. … [Trackback]

    […] Find More on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  24. … [Trackback]

    […] Find More Info here to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  25. … [Trackback]

    […] Find More on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  26. … [Trackback]

    […] Read More on on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  27. … [Trackback]

    […] Read More Info here on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  28. … [Trackback]

    […] Info to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  29. … [Trackback]

    […] Here you can find 26014 more Information on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  30. … [Trackback]

    […] There you can find 67993 additional Info to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  31. … [Trackback]

    […] Information on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  32. … [Trackback]

    […] Read More Info here to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  33. … [Trackback]

    […] Find More to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  34. … [Trackback]

    […] Read More on on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  35. … [Trackback]

    […] Read More Info here to that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  36. … [Trackback]

    […] Information on that Topic: genuinecoder.com/student-record-ccpp-source-code-windows-html/ […]

  37. kamagra du jour au lendemain aucun script

    achat kamagra france acheter

  38. buying enclomiphene generic is good

    purchase enclomiphene generic when will be available

  39. buying androxal cheap canada

    cheap androxal usa overnight delivery

  40. discount dutasteride buy in australia

    how to order dutasteride cost at costco

  41. cheap flexeril cyclobenzaprine without prescription

    order flexeril cyclobenzaprine purchase generic

  42. buy cheap gabapentin usa buy online

    gabapentin prices walmart

  43. buying itraconazole generic now

    buy cheap itraconazole cheap genuine

  44. order fildena united kingdom

    order fildena usa where to buy

  45. canadian staxyn with no prescription

    buying staxyn generic online cheapest

  46. how to buy avodart without prescriptions uk

    how to order avodart overnight no rx

  47. overnight buy xifaxan

    ordering xifaxan spain over the counter

  48. how to order rifaximin us prices

    cheap rifaximin buy online canada

  49. kamagra online bez lテゥkaナ冱kテゥho pナ册dpisu

    obecná lékárna usa kamagra

Leave a Reply Cancel reply

Exit mobile version