18CS306 - Programming Using CPP - 191CS456 - Task1
18CS306 - Programming Using CPP - 191CS456 - Task1
BASED LAB
TASK REPORT
1
TITLE OF THE TASK
Submitted by
ANOOSKAVIN G
ANOOSKAVIN G
1
BANNARI AMMAN INSTITUTE OF TECHNOLOGY
(An Autonomous Institution Affiliated to Anna University, Chennai)
SATHYAMANGALAM-638401
OCTOBER 2020
DECLARATION
I affirm that the lab task work titled “Data Maintenance System in an
Educational Institution” being submitted as the record of original work done by us under
the guidance of Ms RAMYA R NAME OF THE SUBJECT HANDLING FACULTY,
Designation, Department of COMPUTER SCIENCE AND ENGINEERING.
ANOOSKAVIN G
191CS119
3
TABLE OF CONTENTS
1. INTRODUCTION 5
6 OUTPUT 11
7 RESULT 12
12
8
CONCLUSION
4
INTRODUCTION
The ultimate use of c++ language is their OOPS concepts as their class
and objects are useful in creating the complex task as in this report, Let we
obtain the above data maintenance using these above concepts.
ARRAY AS OBJECTS: The array of type class contains the objects of the
class as its individual elements. Thus, an array of a class type is also known
as an array of objects.
5
ALGORITHM OF THE TASK
1. Create a base class as person with name and age as data members
3. Create student class with marks (array) and cur_id (static) as data
members, putdata () and getdata () as the member function to get and
print their details
4. The professor and student should be inherited from the person class
with hierarchical inheritance concept
5. In the main function get the no of records to be inserted from the user
and assign the object value by using the array as object method
6. Construct the for loop with inside a if condition so when the user
enter 1 it points to enter professor record and 2 to student record
7. Finally, again using the for loop print the values back which we have
got from the user.
6
FLOW CHART
PERSON
String Name
Int age
PROFESSOR STUDENT
Getdata() Getdata ()
Putdata () Putdata ()
7
start
Get no of records
to be inserted
1 2
Choice
Print the
records
PROGRAM
#include <iostream>
using namespace std;
#define MAX 30
class student
{
private:
char name[30];
int age;
int marks[5];
int total;
public:
void getdata(void);
void putdata(void);
};
class professor
{
private:
char name[30];
int age;
int publications;
public:
void getdata(void);
void putdata(void);
};
void professor::getdata(void){
cin >> name>> age>> publications;
}
void professor::putdata(void){
cout << name << " " << age << " " << publications;
}
void student::getdata(void){
cin >> name>> age>> marks[0]>> marks[1]>> marks[2]>> marks[3]>> marks[4]
>> marks[5];
total=s1+s2+s3+s4+s5+s6;
}
void student::putdata(void){
cout << name<<" "<< age<<" " << total ;
int main()
{
student std[MAX];
9
professor prof[MAX];
int n,loop,obj,j=1,a[MAX],b=1;
cin >> n;
for(loop=0;loop< n; loop++){
cin>>obj;
if(obj==2)
{
std[loop].getdata();
a[loop]=obj;
}
else
{
prof[loop].getdata();
a[loop]=obj;
}
}
cout << endl;
for(loop=0;loop< n; loop++){
if(a[loop]==2)
{
std[loop].putdata();
cout<<" "<<j<<"\n";
j=j+1;
}
else
{
prof[loop].putdata();
cout<<" "<<b<<"\n";
b=b+1;
}
}
return 0;
}
10
OUTPUT
11
RESULT
Hence by using the oops concepts in the c++ the above program
was executed successfully
CONCLUSION
The final aim of the program to collect and store the professor and student
details achieved by use of the c++ oops concepts and was executed successfully.
12