Student Information in C++
C++ Programming

Student Management System using Function Overloading using OOP in C++

 

Create a class for students containing data members: – Roll_no, name, marks1, marks2, and marks3. Use the Function overloading concept (where possible) and write necessary member functions: (i) To accept details of all students. (ii) To display details of one student. (iii) To display details of all students.

Student Management System OOP Project in C++

‪#include<iostream.h>
#include<stdio.h>
#include<string.h>

class
{
public:
int roll_no;
char firstname[20];
char lastname[20];
int mark;
}student;
int main()
{
int flag,choice, shift,rollnumber,found,continu,length;
char studentname[20];
FILE *fp;
cout<<“————————————————————-“<<endl;
cout<<“\n\t STUDENT DATABASE SYSTEM”;
Label1:
cout<<endl<<“1 -> Store a new record in database”<<endl;
cout<<“2 -> Search a student record by rollNo”<<endl;
cout<<“3 -> Quit Student Database”<<endl;
cout<<endl<<endl;
cout<<“Enter your choice : “;
cin>>choice;
switch(choice)
{
//————————————————————————
case 1:
//————————————————————————
Label2:
cout<<endl<<“Enter Student Details:”<<endl<<endl<<“Roll number (Integer): “;
cin>>student.roll_no;
cout<<endl<<“First Name:”;
cin>>student.firstname;
cout<<endl<<“Last Name:”;
cin>>student.lastname;
cout<<endl<<“Mark(0 – 100 integer) : “;
cin>>student.mark;
fp=fopen(“officefile.txt”,”a+”);
fprintf(fp,”\n%d\t%s\t%s\t%d\t”,student.roll_no,student.firstname,student.lastname,student.mark);
fclose(fp);
cout<<“A student record has been added successfully…”<<endl;
cout<<endl<<endl<<“1 -> Wish to add another record to database”;
cout<<endl<<“2 -> Wish to move to Main Menu”;
cout<<endl<<“3 -> Exit from Program”<<endl;
cin>>shift;
if(shift==1)
goto Label2;
if(shift==2)
goto Label1;
if(shift==3)
break;
if(shift!=1&&2&&3){
cout<<“Exiting………”;
break;
}
//————————————————————————
case 2:
//————————————————————————
Label6:
cout<<endl<<“Enter the rollnumber: “;
cin>>rollnumber;
cout<<“Searching record with rollnumber = “<<rollnumber<<endl;
found=0;
if((fp=fopen(“officefile.txt”,”r”))==NULL)
{
cout<<” ! The File is Empty…”<<endl<<endl;
}
else
{
while(!feof(fp)&& found==0)
{
fscanf(fp,”\n%d\t%s\t%s\t%d\t”,&student.roll_no,student.firstname,student.lastname,&student.mark);
if(student.roll_no==rollnumber)
found=1;
}
}
if(found)
{
cout<<endl<<“The record is found.”;
printf(“\nRoll no: %d\nName: %s\nSurname: %s\nMark: %d \n”,student.roll_no,student.firstname,student.lastname,student.mark);
}
else
{
cout<<“Not found…”<<endl;
getchar();
}
Label7:
cout<<endl<<endl<<“1 -> Wish to search more..”;
cout<<endl<<“2 -> Wish to move to Main Menu”;
cout<<endl<<“3 -> Exit from Program”<<endl;
cin>>shift;
if(shift==1)
goto Label6;
if(shift==2)
goto Label1;
if(shift==3)
break;
if(shift!=1&&2&&3){
cout<<endl<<“Enter a valid choice”;
goto Label7;
}
//————————————————————————
case 3: break;
//————————————————————————
}
getchar();
return 0;
}

Output:

Student Management project in C++

Recommended Posts

C++ Programming

Visibility modes in C++

In C++, visibility modes refer to the accessibility of class members (such as variables and functions) from different parts of a program. C++ provides three visibility modes: public, private, and protected. These modes control the access levels of class members concerning the outside world and derived classes. Public: Members declared as public are accessible from […]

Rekha Setia 
C++ Programming

Inheritance in C++

In C++, inheritance is a fundamental concept of object-oriented programming (OOP) that allows you to create a new class based on an existing class, known as the base or parent class. The new class is called the derived or child class. Inheritance facilitates code reuse and supports the creation of a hierarchy of classes. There […]

Rekha Setia 
C++ Programming

C++ Classes and Objects

In C++, classes and objects are fundamental concepts that support object-oriented programming (OOP). Here’s a brief overview of classes and objects in C++: Classes: In C++, a class is a user-defined data type that allows you to encapsulate data members and member functions into a single unit. Classes are the building blocks of object-oriented programming […]

Rekha Setia 

Leave A Comment