Professional Documents
Culture Documents
Anjana S 20104014 OOP Lab Program 1
Anjana S 20104014 OOP Lab Program 1
Anjana S 20104014 OOP Lab Program 1
Anjana S
20104014
AIM:
To Write a C++ program for Students mark analysis using Static Data
member, Default Argument and Friend Function.
ALGORITHM:
Step 2: Get the Students detail and calculate the Result analysis.
Step 3: Default value is assigned for pass in a function and the function is
assigned with default value when value for pass is not given in checking for
pass status.
Step 4: Declare the integer count as Static member each time when the
student is pass it will be incremented and finally specify pass count.
Step 5: The friend function display is used to access the private variables from
two classes and acting as the bridge between two classes.
PROGRAM:
#include <iostream>
int cp(int,int,int,int=50);
void printline(char ch='`',int rage =70);
class per;
class acc
int rno,tot;
int m1,m2,m3;
char name[30],grade;
float avg;
public:
void getdata()
cin>>rno;
cin>>name;
cin>>m1>>m2>>m3;
void cal()
tot=0;
if(cp(m1,m2,m3))
{
cout<<"Result=pass"<<endl;
tot=m1+m2+m3;
avg=tot/3;
count=count+1;
if(avg>=90)
grade='O';
grade='A';
grade='B';
else
cout<<"Result=Fail"<<endl; }
cout<<endl;
cout<<"count:"<<count; }
};
int acc::count;
class per
char add[30];
long tel;
public:
void getdata1()
cin>>add;
cin>>tel;
cout<<endl;
cout<<"Name:"<<a.name<<endl;
cout<<"ID:"<<a.rno<<endl;
cout<<"Address:"<<p.add<<endl;
cout<<"Total:"<<a.m1<<endl;
cout<<"Average:"<<a.avg<<endl;
cout<<"Grade:"<<a.grade<<endl; }
};
return(1);
else
return(0);
int main()
int i,n;
per p1[20];
acc a1[20];
cin>>n;
for(i=0;i<n;i++)
a1[i].getdata();
p1[i].getdata1();
a1[i].cal();
for(i=0;i<n;i++)
printline('-');
display(a1[i],p1[i]);
printline();
acc::showcount();
return 0;
int i;
cout<<endl;
for(i=0;i<range;i++)
cout<<ch; }
OUTPUT:
RESULT:
Thus the program to perform Students mark analysis using Static Data
member, Default Argument and Friend Function was implemented.