/*Write a program that accepts the details of students including name,
university register number, sessional marks and university marks.
Print the mark list and use friend function to determine whether the student
has passed in each subject or not. Use constructors to initialize the student
details.
*/
#include
#include
class stud
{
char name[25];
char reg[20];
int ses[6],stot;
int unv[6],utot;
public:
stud()
{
cout<<"Enter the name: ";
cin>>name;
cout<<"Enter the regester number: ";
cin>>reg;
cout<<"Enter the session marks: ";
for(int i=0;i<6;i++)
cin>>ses[i];
cout<<"Enter the University marks: ";
for(int j=0;j<6;j++)
cin>>unv[j];
stot=0;
utot=0;
}
void calc()
{
for(int i;i<6;i++)
{
stot+=ses[i];
utot+=unv[i];
}
}
void disp()
{
calc();
cout<<"Name: "<
cout<<"\\nRegister Number: "<< reg;
cout<<"\\nSessional marks: ";
for(int i=0;i<6;i++)
cout<<<" ";
cout<<"Total Sessional Marks= "<
cout<<"\\n University Marks: ";
for(int j=0;j<6;j++)
cout<<<" ";
cout<<"\\nTotal University Marks= "<
}
friend void check(stud s);
};
void check(stud s)
{
s.calc();
if((s.stot+s.utot)>=450)
cout<<"\\nStudent has Passed";
else
cout<<"\\nStudent has Failed";
}
void main()
{
clrscr();
stud s[2];
for(int i=0;i<2;i++)
{
s[i].disp();
check(s[i]);
getch();
}
}
/*Write a program that accepts the details of students including name,
university register number, sessional marks and university marks.
Print the mark list and use friend function to determine whether the student
has passed in each subject or not. Use constructors to initialize the student
details.
*/
#include<iostream.h>
#include<conio.h>
class stud
{
char name[25];
char reg[20];
int ses[6],stot;
int unv[6],ytot;
public:
stud()
{
cout<<"Enter the name: ";
cin>>name;
cout<<"Enter the regester number: ";
cin>>reg;
cout<<"Enter the session marks: ";
for(int i=0;i<6;i++)
cin>>ses[i];
cout<<"Enter the University marks: ";
for(int j=0;j<6;j++)
cin>>unv[j];
stot=0;
utot=0;
}
void calc()
{
for(int i;i<6;i++)
{
stot+=ses[i];
utot+=unv[i];
}
}
void disp()
{
calc();
cout<<"Name: "<<name;
cout<<"\nRegister Number: "<< reg;
cout<<"\nSessional marks: ";
for(int i=0;i<6;i++)
cout<<ses[i]<<"\n";
cout<<"Total Sessional Marks= "<<stot;
cout<<"\nUniversity Marks: ";
for(int j=0;j<6;j++)
cout<<unv[j]<<"\n";
cout<<"Total University Marks= "<<utot;
}
friend void check(stud s);
};
void check(stud s)
{
s.calc();
if((s.stot+s.utot)>=75)
cout<<"Passed";
else
cout<<"Failed";
}
void main()
{
stud s[5];
for(int i=0;i<5;i++)
{
s[i].disp();
check(s[i]);
getch();
}
}/*Write a program that accepts the details of students including name,
university register number, sessional marks and university marks.
Print the mark list and use friend function to determine whether the student
has passed in each subject or not. Use constructors to initialize the student
details.
*/
#include<iostream.h>
#include<conio.h>
class stud
{
char name[25];
char reg[20];
int ses[6],stot;
int unv[6],utot;
public:
stud()
{
cout<<"Enter the name: ";
cin>>name;
cout<<"Enter the regester number: ";
cin>>reg;
cout<<"Enter the session marks: ";
for(int i=0;i<6;i++)
cin>>ses[i];
cout<<"Enter the University marks: ";
for(int j=0;j<6;j++)
cin>>unv[j];
stot=0;
utot=0;
}
void calc()
{
for(int i;i<6;i++)
{
stot+=ses[i];
utot+=unv[i];
}
}
void disp()
{
calc();
cout<<"Name: "<<name;
cout<<"\nRegister Number: "<< reg;
cout<<"\nSessional marks: ";
for(int i=0;i<6;i++)
cout<<ses[i]<<"\n";
cout<<"Total Sessional Marks= "<<stot;
cout<<"\nUniversity Marks: ";
for(int j=0;j<6;j++)
cout<<unv[j]<<"\n";
cout<<"Total University Marks= "<<utot;
}
friend void check(stud s);
};
void check(stud s)
{
s.calc();
if((s.stot+s.utot)>=75)
cout<<"Passed";
else
cout<<"Failed";
}
void main()
{
stud s[5];
for(int i=0;i<5;i++)
{
s[i].disp();
check(s[i]);
getch();
}
}
#include<iostream.h>
#include<conio.h>
#include<process.h>
struct student
{
char reg_no[15];
char name[30];
int marks[6];
};
int tot[50],n;
void highest(student s[]);
void lowest(student s[]);
void total(student s[]);
void main()
{
student s[10];
int i,j,c;
clrscr();
cout<<"Enter the number of students ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter the details of student "<<i+1;
cout<<"\nEnter the register number ";
cin>>s[i].reg_no;
cout<<"Enter the name ";
cin>>s[i].name;
cout<<"Enter the marks of 6 subjects ";
for(j=0;j<6;j++)
{
cin>>s[i].marks[j];
}
clrscr();
}
do
{
clrscr();
cout<<"\n\n\n\n\t\t\tMAIN MENU\n\n\t\t1.Display the total of all students\n\t\t2.Display the details of student scored highest marks\n\t\t3.Display the details of student scored lowest marks\n\t\t4.Exit\n\n\t\tEnter your choice :";
cin>>c;
switch(c)
{
case 1:total(s);
break;
case 2:highest(s);
break;
case 3:lowest(s);
break;
case 4:exit(0);
default : cout<<"Enter the correct choice .............";
}
}
while(c!=0);
}
void highest(student s[])
{
int i,l,j;
for(i=0;i<n;i++)
{
tot[i]=0;
for(j=0;j<6;j++)
tot[i]+=s[i].marks[j];
}
l=tot[0];
for(i=1;i<n;i++)
{
if(l<tot[i])
l=tot[i];
}
clrscr();
cout<<"Details of students secured highest marks ";
for(i=0;i<n;i++)
{
if(l==tot[i])
{
cout<<"\nRegister number : "<<s[i].reg_no;
cout<<"\nName : "<<s[i].name;
cout<<"\nTotal : "<<tot[i];
}
}
getch();
}
void lowest(student s[])
{
int i,l,j;
for(i=0;i<n;i++)
{
tot[i]=0;
for(j=0;j<6;j++)
tot[i]+=s[i].marks[j];
}
l=tot[0];
for(i=1;i<n;i++)
{
if(l>tot[i])
l=tot[i];
}
clrscr();
cout<<"Details of students secured lowest marks ";
for(i=0;i<n;i++)
{
if(l==tot[i])
{
cout<<"\nRegister number : "<<s[i].reg_no;
cout<<"\nName : "<<s[i].name;
cout<<"\nTotal : "<<tot[i];
}
}
getch();
}
void total(student s[])
{
int i,l,j;
for(i=0;i<n;i++)
{
tot[i]=0;
for(j=0;j<6;j++)
tot[i]+=s[i].marks[j];
}
clrscr();
for(i=0;i<n;i++)
{
cout<<"\nRegister number : "<<s[i].reg_no;
cout<<"\nName : "<<s[i].name;
cout<<"\nTotal : "<<tot[i];
}
getch();
}
/* OUTPUT
Enter the number of students 2
Enter the details of student 1
Enter the register number cs001
Enter the name aneesh
Enter the marks of 6 subjects 80 65 90 94 82 75
Enter the details of student 2
Enter the register number cs002
Enter the name arun
Enter the marks of 6 subjects 76 84 72 75 90 81
MAIN MENU
1.Display the total of all students
2.Display the details of student scored highest marks
3.Display the details of student scored lowest marks
4.Exit
Enter your choice :1
Register number : cs001
Name : aneesh
Total : 486
Register number : cs002
Name : arun
Total : 478
MAIN MENU
1.Display the total of all students
2.Display the details of student scored highest marks
3.Display the details of student scored lowest marks
4.Exit
Enter your choice :4 */
#include<iostream.h>
#include<conio.h>
class stud
{
char name[25];
char reg[20];
int ses[6],stot;
int unv[6],utot;
public:
stud()
{
cout<<"Enter the name: ";
cin>>name;
cout<<"Enter the regester number: ";
cin>>reg;
cout<<"Enter the session marks: ";
for(int i=0;i<6;i++)
cin>>ses[i];
cout<<"Enter the University marks: ";
for(int j=0;j<6;j++)
cin>>unv[j];
stot=0;
utot=0;
}
void calc()
{
for(int i;i<6;i++)
{
stot+=ses[i];
utot+=unv[i];
}
}
void disp()
{
calc();
cout<<"\n\nName: "<<name;
cout<<"\nRegister Number: "<< reg;
cout<<"\nSessional marks: ";
for(int i=0;i<6;i++)
cout<<ses[i]<<" ";
cout<<"\nTotal Sessional Marks= "<<stot;
cout<<"\nUniversity Marks: ";
for(int j=0;j<6;j++)
cout<<unv[j]<<" ";
cout<<"\nTotal University Marks= "<<utot;
}
friend void check(stud s);
};
void check(stud s)
{
s.calc();
if((s.stot+s.utot)>=75)
cout<<"\nPassed";
else
cout<<"\nFailed";
}
void main()
{
clrscr();
stud s[2];
for(int i=0;i<2;i++)
{
s[i].disp();
check(s[i]);
}
getch();
}
/* OUTPUT
Enter the name: arun
Enter the regester number: 001
Enter the session marks: 34 35 36 37 38 40
Enter the University marks: 84 74 85 95 75 78
Enter the name: aneesh
Enter the regester number: 002
Enter the session marks: 45 46 38 49 57 58
Enter the University marks: 86 84 85 75 90 85
Name: arun
Register Number: 001
Sessional marks: 34 35 36 37 38 40
Total Sessional Marks= 220
University Marks: 84 74 85 95 75 78
Total University Marks= 491
Passed
Name: aneesh
Register Number: 002
Sessional marks: 45 46 38 49 57 58
Total Sessional Marks= 248
University Marks: 86 84 85 75 90 85
Total University Marks= 419
Passed */
#include<iostream.h>
#include<conio.h>
#include<process.h>
void area(float,float);
void area(float);
void area(float,float,float);
void main()
{
float a,b,c;
int d;
do
{
clrscr();
cout<<"\n\n\n\t\t\tMAIN MENU\n\n\t\t1.Calculate the area of a cuboid\n\t\t2.Calculate the area of a rectangle\n\t\t3.Calculate the area of a circle\n\t\t4.Exit \n\n\t\tEnter your choice : ";
cin>>d;
switch(d)
{
case 1:clrscr();
cout<<"Enter the length breadth height of a cuboid :";
cin>>a>>b>>c;
area(a,b,c);
break;
case 2:clrscr();
cout<<"Enter the length breadth of a rectangle :";
cin>>a>>b;
area(a,b);
break;
case 3:clrscr();
cout<<"Enter the radius of a circle :";
cin>>a;
area(a);
break;
case 4:exit(0);
default :cout<<"Enter the correct choice .............";
}
}
while(d!=0);
}
void area(float a)
{
float area;
area=3.14*a*a;
cout<<"Area of circle = "<<area;
getch();
}
void area(float a,float b)
{
float area;
area=a*b;
cout<<"Area of rectangle = "<<area;
getch();
}
void area(float a,float b,float c)
{
float area;
area=2*((a*b)+(a*c)+(b*c));
cout<<"Area of cuboid = "<<area;
getch();
}
/* OUTPUT
MAIN MENU
1.Calculate the area of a cuboid
2.Calculate the area of a rectangle
3.Calculate the area of a circle
4.Exit
Enter your choice : 2
Enter the length breadth of a rectangle :25 35
Area of rectangle = 875
MAIN MENU
1.Calculate the area of a cuboid
2.Calculate the area of a rectangle
3.Calculate the area of a circle
4.Exit
Enter your choice : 4 */
#include<iostream.h>
#include<conio.h>
#include<process.h>
void area1(float a=5,float b=5);
void area2(float a=5);
void area3(float a=5,float b=5,float c=5);
void main()
{
float a,b,c;
int d;
do
{
clrscr();
cout<<"\n\n\n\t\t\tMAIN MENU\n\n\t\t1.Calculate the area of a cuboid\n\t\t2.Calculate the area of a rectangle\n\t\t3.Calculate the area of a circle\n\t\t4.Exit \n\n\t\tEnter your choice : ";
cin>>d;
switch(d)
{
case 1:clrscr();
cout<<"Enter the length breadth height of a cuboid :";
cin>>a>>b>>c;
area3(a,b,c);
cout<<"\nBy default values as 5 \n";
area3();
break;
case 2:clrscr();
cout<<"Enter the length breadth of a rectangle :";
cin>>a>>b;
area1(a,b);
cout<<"\nBy default values as 5 \n";
area1();
break;
case 3:clrscr();
cout<<"Enter the radius of a circle :";
cin>>a;
area2(a);
cout<<"\nBy default values as 5 \n";
area2();
break;
case 4:exit(0);
default :cout<<"Enter the correct choice .............";
}
}
while(d!=0);
}
void area2(float a)
{
float area;
area=3.14*a*a;
cout<<"Area of circle = "<<area;
getch();
}
void area1(float a,float b)
{
float area;
area=a*b;
cout<<"Area of rectangle = "<<area;
getch();
}
void area3(float a,float b,float c)
{
float area;
area=2*((a*b)+(a*c)+(b*c));
cout<<"Area of cuboid = "<<area;
getch();
}
/* OUTPUT
MAIN MENU
1.Calculate the area of a cuboid
2.Calculate the area of a rectangle
3.Calculate the area of a circle
4.Exit
Enter your choice : 3
Enter the radius of a circle :12
Area of circle = 452.160004
By default values as 5
Area of circle = 78.5
MAIN MENU
1.Calculate the area of a cuboid
2.Calculate the area of a rectangle
3.Calculate the area of a circle
4.Exit
Enter your choice : 4 */
#include<iostream.h>
#include<conio.h>
class stud
{
char name[25];
int regno,m[6],tot;
public:
void read();
void marksheet();
void hilow(int);
}det[50];
void main()
{
int n;
clrscr();
cout<<"enter the number of students\n";
cin>>n;
for(int i=0;i<n;i++)
{
det[i].read();
det[i].marksheet();
}
det[0].hilow(n);
getch();
}
void stud::read()
{
cout<<"enter name: ";
cin>>name;
cout<<"\nenter registration number ";
cin>>regno;
cout<<"enter the marks ;\n";
for(int j=0;j<6;j++)
{
cin>>m[j];
}
}
void stud::marksheet()
{
tot=0;
for(int j=0;j<6;j++)
tot+=m[j];
cout<<"total mark of student "<<": "<<tot<<"\n";
}
void stud::hilow(int n)
{
int h=det[0].tot,l=det[0].tot;
for(int i=0;i<n;i++)
{
if(det[i].tot>h)
h=det[i].tot;
if(det[i].tot<l)
l=det[i].tot;
}
for(i=0;i<n;i++)
{
if(h==det[i].tot)
{
cout<<"\n\t highest mark secured by\n";
cout<<"\t name: "<<det[i].name<<"\n";
cout<<"\tregistration no: "<<det[i].regno<<"\n";
cout<<"\ttotal marks obtained is "<<det[i].tot;
}}
for(i=0;i<n;i++)
{
if (l==det[i].tot)
{ cout<<"\n\t lowest mark secured by\n";
cout<<"\t name: "<<det[i].name<<"\n";
cout<<"\ttotal mark obtianed is: "<<det[i].tot;
}}}
/* OUTPUT
enter the number of students
2
enter name: aneesh
enter registration number 001
enter the marks ;
56 60 80 73 91 85
total mark of student : 445
enter name: arun
enter registration number 002
enter the marks ;
60 84 76 72 76 67
total mark of student : 435
highest mark secured by
name: aneesh
registration no: 1
total marks obtained is 445
lowest mark secured by
name: arun
total mark obtianed is: 435 */
#include<iostream.h>
#include<conio.h>
#include<process.h>
class bank
{
char name[30];
float balance;
public:
static int ac;
int accno;
void read();
void dep();
void with();
}c[20];
int bank::ac=10214;
void bank::read()
{
accno=ac++;
cout<<"\nEnter the name ";
cin>>name;
cout<<"Enter the balance ";
cin>>balance;
}
void bank::dep()
{
float x;
cout<<"Enter the amount : ";
cin>>x;
balance+=x;
cout<<"YOUR CURRENT BALANCE IS "<<balance;
getch();
}
void bank::with()
{
float x;
cout<<"Enter the amount : ";
cin>>x;
balance-=x;
cout<<"YOUR CURRENT BALANCE IS "<<balance;
getch();
}
int n;
void main()
{
int i,d,a;
clrscr();
cout<<"Enter the number of customers ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter the details of customer "<<i+1;
c[i].read();
}
do
{
cout<<"\n\n\n\n\t\t\tMAIN MENU\n\n\t\t1.Add new customer\n\t\t2.deposit\n\t\t3.Withdraw\n\t\t4.Exit\n\n\t\tEnter your choice :";
cin>>d;
switch(d)
{
case 1:c[n].read();
n++;
break;
case 2:cout<<"Enter the account number ";
cin>>a;
for(i=0;i<n;i++)
{
if(c[i].accno==a)
c[i].dep();
}
break;
case 3:cout<<"Enter the account number ";
cin>>a;
for(i=0;i<n;i++)
{
if(c[i].accno==a)
c[i].with();
}
break;
case 4:exit(0);
default : cout<<"Enter the correct choice .............";
}
}
while(c!=0);
}
/* OUTPUT
Enter the number of customers 2
Enter the details of customer 1
Enter the name aneesh
Enter the balance 2540
Enter the details of customer 2
Enter the name anu
Enter the balance 5020
MAIN MENU
1.Add new customer
2.deposit
3.Withdraw
4.Exit
Enter your choice :2
Enter the account number 10215
Enter the amount : 6000
YOUR CURRENT BALANCE IS 11020
MAIN MENU
1.Add new customer
2.deposit
3.Withdraw
4.Exit
Enter your choice :4 */
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void add(long,long);
void add(double,double);
void add(char[],char[]);
void main(int argc,char *argv[])
{
clrscr();
if(strcmp(argv[1],"int")==0)
{
char * endptr1,* endptr2;
long a,b;
a=strtol(argv[2],&endptr1,10);
b=strtol(argv[3],&endptr2,10);
add(a,b);
}
else if(strcmp(argv[1],"double")==0)
{
char *endptr1,*endptr2;
double c,d;
c=strtod(argv[2],&endptr1);
d=strtod(argv[3],&endptr2);
add(c,d);
}
else if(strcmp(argv[1],"string")==0)
{
add(argv[2],argv[3]);
}
getch();
}
void add(long A,long B)
{
cout<<"Sum of 2 integers is "<<A+B;
}
void add(double c,double d)
{
cout<<"Sum of 2 double values is "<<c+d;
}
void add(char x[],char y[])
{
cout<<"Concatinated string is "<<strcat(x,y);
}
/* OUTPUT
arguement inputs are string copm uter
Concatinated string is computer */
//Program to inherit details from personal
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
int n;
class personal
{
protected :
char name[25];
char address[100];
int age;
long phno;
char bg[5];
};
class academic : personal
{
char branch[20];
int sem;
char rollno[25];
int pcnt[8];
int totpcnt;
public :
void read();
void edit(char[]);
void disp();
}s[10];
void academic :: read()
{
cout<<"\nEnter the name: ";
gets(name);
cout<<"Enter the Address: ";
gets(address);
cout<<"Enter the age: ";
cin>>age;
cout<<"Enter the phone number: ";
cin>>phno;
cout<<"Enter the blood group: ";
cin>>bg;
cout<<"Enter the branch: ";
gets(branch);
cout<<"Enter the Semester: ";
cin>>sem;
cout<<"Enter the roll no: ";
cin>>rollno;
if(sem>3)
{
cout<<"Enter the percentage of marks in semseters published: ";
for(int i=0;i<sem-2;i++)
{
cin>>pcnt[i];
}
}
}
void academic :: edit(char a[])
{
for(int i=0;i<n;i++)
{
if(strcmp(s[i].rollno,a)==0)
{
s[i].sem++;
cout<<"\nEnter the percentage in Sem"<<s[i].sem;
cin>>s[i].pcnt[sem-3];
s[i].totpcnt+=s[i].pcnt[sem-3];
}
}
}
void academic :: disp()
{
int i;
cout<<"\nName: ";
puts(name);
cout<<"\nAddress: ";
puts(address);
cout<<"\nAge: "<<age;
cout<<"\nPhone number: "<<phno;
cout<<"\nBlood group: "<<bg;
cout<<"\nBranch: ";
puts(branch);
cout<<"\nSemester: "<<sem;
cout<<"\nRoll no: "<<rollno;
if(sem>3)
{
cout<<"\nPercentage of marks in semseters published: ";
totpcnt=0;
for(i=0;i<sem-2;i++)
{
cout<<pcnt[i]<<" ";
totpcnt+=pcnt[i];
}
} cout<<"\nTotal Percentage: "<<totpcnt/(i);
}
void main()
{ clrscr();
int c;
char a[25];
char ch;
cout<<"Enter the number of students: ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"Enter the details of student "<<i+1;
s[i].read();
}
do
{
cout<<"\t\t\t Menu \t\n";
cout<<"1.Add Student\n";
cout<<"2.Edit Details\n";
cout<<"3.Display Details\n";
cout<<"Enter your choice: :";
cin>>c;
switch(c)
{
case 1:s[n].read();
cout<<"\nStudent details added";
n++;
break;
case 2:cout<<"\nEnter the roll no: ";
cin>>a;
s[0].edit(a);
cout<<"\nStudent details have been edited ";
break;
case 3:for(int i=0;i<n;i++)
{
cout<<"\nThe details of student "<<i+1;
s[i].disp();
}
break;
default:cout<<"\nWrong Choice";
}
cout<<"\nDo you want to continue?? ";
cin>>ch;
}while(ch=='y'||ch=='Y');
getch();
}
//Program to inherit details from personal
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
int n;
class personal
{
protected :
char name[25];
char address[100];
char dob[20];
char sex[10];
char bg[5];
};
class student : personal
{
char branch[20];
int sem;
char rollno[25];
int pcnt[8];
int admno;
int yr;
public :
void read();
void edit(char[]);
void disp();
void show(int);
}s[10];
void student :: read()
{
cout<<"\nEnter the name: ";
gets(name);
cout<<"Enter the Address: ";
gets(address);
cout<<"Enter the Date of Birth: ";
gets(dob);
cout<<"Enter the Sex: ";
cin>>sex;
cout<<"Enter the blood group: ";
cin>>bg;
cout<<"Enter the Admission number: ";
cin>>admno;
cout<<"Enter the year of join: ";
cin>>yr;
cout<<"Enter the branch: ";
gets(branch);
cout<<"Enter the Semester: ";
cin>>sem;
cout<<"Enter the roll no: ";
cin>>rollno;
if(sem>3)
{
cout<<"Enter the percentage of marks in semseters published: ";
for(int i=0;i<sem-2;i++)
{
cin>>pcnt[i];
}
}
}
void student :: edit(char a[])
{
for(int i=0;i<n;i++)
{
if(strcmp(s[i].rollno,a)==0)
{
s[i].sem++;
cout<<"\nEnter the percentage in Sem"<<s[i].sem;
cin>>s[i].pcnt[sem-3];
}
}
}
void student :: disp()
{
int i;
cout<<"\nName: ";
puts(name);
cout<<"\nAddress: ";
puts(address);
cout<<"\nDate of birth: ";
puts(dob);
cout<<"\nSex: "<<sex;
cout<<"\nBlood group: "<<bg;
cout<<"\nBranch: ";
puts(branch);
cout<<"\nAdmission Number: "<<admno;
cout<<"\nYear of Join: "<<yr;
cout<<"\nSemester: "<<sem;
cout<<"\nRoll no: "<<rollno;
if(sem>3)
{
cout<<"\nPercentage of marks in semseters published: ";
for(i=0;i<sem-2;i++)
{
cout<<pcnt[i]<<" ";
}
}
}
void student :: show(int b)
{
int k;
cout<<"Details of student(s) who joined in the year "<<b;
for(k=0;k<n;k++)
{
if(b==s[k].yr)
{
cout<<"\nName: "<<s[k].name;
cout<<"\nAddress: "<<s[k].address;
cout<<"\nDate of birth: "<<s[k].dob;
cout<<"\nSex: "<<s[k].sex;
cout<<"\nBlood group: "<<s[k].bg;
}
}
}
void main()
{ clrscr();
int c,b;
char a[25];
char ch;
cout<<"Enter the number of students: ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"Enter the details of student "<<i+1;
s[i].read();
}
do
{
cout<<"\t\t\t Menu \t\n";
cout<<"1.Add Student\n";
cout<<"2.Edit Details\n";
cout<<"3.Display Details\n";
cout<<"4.Details of student who joined in a year\n";
cout<<"Enter your choice: ";
cin>>c;
switch(c)
{
case 1:s[n].read();
cout<<"\nStudent details added";
n++;
break;
case 2:cout<<"\nEnter the roll no: ";
cin>>a;
s[0].edit(a);
cout<<"\nStudent details have been edited ";
break;
case 3:for(int i=0;i<n;i++)
{
cout<<"\nThe details of student "<<i+1;
s[i].disp();
}
break;
case 4:cout<<"\nEnter the year of admission: ";
cin>>b;
s[0].show(b);
break;
default:cout<<"\nWrong Choice";
}
cout<<"\nDo you want to continue?? ";
cin>>ch;
}while(ch=='y'||ch=='Y');
getch();
}
Write a program that creates a class containing personal
details of individuals. Create another class student that contains
the details of student and personal information. Create another class
academic record that contains the student details and also the
academic records. The program should be able to input, edit and
output details. Print the details of students who have secured
more that eighty percentage of marks in 10th and 12th grade.
Academic Record:
10th grade:
Marks:
School:
12th Grade:
Marks
School
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
int n;
class personal
{
protected:
char name[25];
char address[100];
char dob[20];
char sex[10];
char bg[5];
};
class student : public personal
{
protected:
// char scl[30];
char dob[15];
char branch[20];
int sem;
char rollno[25];
int pcnt[8];
int admno;
int yr;
};
class academic : public student
{
private:
char grade10[3],grade12[3];
int mark10,mark12;
char scl10[20],scl12[25];
public:
void read();
void edit(char[]);
void disp();
void i80();
}s[10];
void academic :: read()
{
cout<<"\nEnter the name: ";
gets(name);
cout<<"Enter the Address: ";
gets(address);
cout<<"Enter the Date of Birth: ";
gets(dob);
cout<<"Enter the Sex: ";
cin>>sex;
cout<<"Enter the blood group: ";
cin>>bg;
cout<<"Enter the marks obtained in 10th: ";
cin>>mark10;
cout<<"Enter the grade in 10th: ";
cin>>grade10;
cout<<"Enter the school of study: ";
cin>>scl10;
cout<<"Enter the marks obtained in 12th: ";
cin>>mark12;
cout<<"Enter th grade in 12th: ";
cin>>grade12;
cout<<"Enter the school of study: ";
cin>>scl12;
cout<<"Enter the Admission number: ";
cin>>admno;
cout<<"Enter the year of join: ";
cin>>yr;
cout<<"Enter the branch: ";
gets(branch);
cout<<"Enter the Semester: ";
cin>>sem;
cout<<"Enter the roll no: ";
cin>>rollno;
if(sem>3)
{
cout<<"Enter the percentage of marks in semseters published: ";
for(int i=0;i<sem-2;i++)
{
cin>>pcnt[i];
}
}
}
void academic :: edit(char a[])
{
for(int i=0;i<n;i++)
{
if(strcmp(s[i].rollno,a)==0)
{
s[i].sem++;
cout<<"\nEnter the percentage in Sem"<<s[i].sem;
cin>>s[i].pcnt[sem-3];
}
}
}
void academic :: disp()
{
int i;
cout<<"\nName: ";
puts(name);
cout<<"\nAddress: ";
puts(address);
cout<<"\nDate of birth: ";
puts(dob);
cout<<"\nSex: "<<sex;
cout<<"\nBlood group: "<<bg;
cout<<"\nBranch: ";
puts(branch);
cout<<"\nMarks scored in 10th: "<<mark10;
cout<<"\nMarks scored in 12th: "<<mark12;
cout<<"\nAdmission Number: "<<admno;
cout<<"\nYear of Join: "<<yr;
cout<<"\nSemester: "<<sem;
cout<<"\nRoll no: "<<rollno;
if(sem>3)
{
cout<<"\nPercentage of marks in semseters published: ";
for(i=0;i<sem-2;i++)
{
cout<<pcnt[i]<<" ";
}
}
}
void academic :: i80()
{
cout<<"Details of student(s) who scored over 80 ";
for(int k=0;k<n;k++)
{
if(s[k].mark10>480 && s[k].mark12>480)
{
cout<<"\nName: "<<s[k].name;
cout<<"\nAddress: "<<s[k].address;
cout<<"\nDate of birth: "<<s[k].dob;
cout<<"\nSex: "<<s[k].sex;
cout<<"\nBlood group: "<<s[k].bg;
}
}
}
void main()
{
clrscr();
int c,b;
char a[25];
char ch;
cout<<"Enter the number of students: ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"Enter the details of student "<<i+1;
s[i].read();
}
do
{
cout<<"\t\t\t Menu \t\n";
cout<<"1.Add Student\n";
cout<<"2.Edit Details\n";
cout<<"3.Display Details\n";
cout<<"4.Details of student who secured 80%+ in 10th n 12th\n";
cout<<"Enter your choice: ";
cin>>c;
switch(c)
{
case 1:s[n].read();
cout<<"\nStudent details added";
n++;
break;
case 2:cout<<"\nEnter the roll no: ";
cin>>a;
s[0].edit(a);
cout<<"\nStudent details have been edited ";
break;
case 3:for(int i=0;i<n;i++)
{
cout<<"\nThe details of student "<<i+1;
s[i].disp();
}
break;
case 4:cout<<"\n ";
s[0].i80();
break;
default:cout<<"\nWrong Choice";
}
cout<<"\nDo you want to continue?? ";
cin>>ch;
}while(ch=='y'||ch=='Y');
getch();
}
//Program to inherit details from personal
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
int n;
class personal
{
protected :
char name[25];
char address[100];
char dob[20];
char sex[10];
char bg[5];
};
class student : personal
{
char branch[20];
int sem;
char rollno[25];
int pcnt[8];
int admno;
int yr;
public :
void read();
void edit(char[]);
void disp();
void show(int);
}s[10];
void student :: read()
{
cout<<"\nEnter the name: ";
gets(name);
cout<<"Enter the Address: ";
gets(address);
cout<<"Enter the Date of Birth: ";
gets(dob);
cout<<"Enter the Sex: ";
cin>>sex;
cout<<"Enter the blood group: ";
cin>>bg;
cout<<"Enter the Admission number: ";
cin>>admno;
cout<<"Enter the year of join: ";
cin>>yr;
cout<<"Enter the branch: ";
gets(branch);
cout<<"Enter the Semester: ";
cin>>sem;
cout<<"Enter the roll no: ";
cin>>rollno;
if(sem>3)
{
cout<<"Enter the percentage of marks in semseters published: ";
for(int i=0;i<sem-2;i++)
{
cin>>pcnt[i];
}
}
}
void student :: edit(char a[])
{
for(int i=0;i<n;i++)
{
if(strcmp(s[i].rollno,a)==0)
{
s[i].sem++;
cout<<"\nEnter the percentage in Sem"<<s[i].sem;
cin>>s[i].pcnt[sem-3];
}
}
}
void student :: disp()
{
int i;
cout<<"\nName: ";
puts(name);
cout<<"\nAddress: ";
puts(address);
cout<<"\nDate of birth: ";
puts(dob);
cout<<"\nSex: "<<sex;
cout<<"\nBlood group: "<<bg;
cout<<"\nBranch: ";
puts(branch);
cout<<"\nAdmission Number: "<<admno;
cout<<"\nYear of Join: "<<yr;
cout<<"\nSemester: "<<sem;
cout<<"\nRoll no: "<<rollno;
if(sem>3)
{
cout<<"\nPercentage of marks in semseters published: ";
for(i=0;i<sem-2;i++)
{
cout<<pcnt[i]<<" ";
}
}
}
void student :: show(int b)
{
int k;
cout<<"Details of student(s) who joined in the year "<<b;
for(k=0;k<n;k++)
{
if(b==s[k].yr)
{
cout<<"\nName: "<<s[k].name;
cout<<"\nAddress: "<<s[k].address;
cout<<"\nDate of birth: "<<s[k].dob;
cout<<"\nSex: "<<s[k].sex;
cout<<"\nBlood group: "<<s[k].bg;
}
}
}
void main()
{ clrscr();
int c,b;
char a[25];
char ch;
cout<<"Enter the number of students: ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"Enter the details of student "<<i+1;
(s+i)->read();
}
do
{
cout<<"\t\t\t Menu \t\n";
cout<<"1.Add Student\n";
cout<<"2.Edit Details\n";
cout<<"3.Display Details\n";
cout<<"4.Details of student who joined in a year\n";
cout<<"Enter your choice: ";
cin>>c;
switch(c)
{
case 1:(s+n)->read();
cout<<"\nStudent details added";
n++;
break;
case 2:cout<<"\nEnter the roll no: ";
cin>>a;
s->edit(a);
cout<<"\nStudent details have been edited ";
break;
case 3:for(int i=0;i<n;i++)
{
cout<<"\nThe details of student "<<i+1;
(s+i)->disp();
}
break;
case 4:cout<<"\nEnter the year of admission: ";
cin>>b;
s[0].show(b);
break;
default:cout<<"\nWrong Choice";
}
cout<<"\nDo you want to continue?? ";
cin>>ch;
}while(ch=='y'||ch=='Y');
getch();
}
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<process.h>
int n;
class personal
{
private :
char name[25];
char address[100];
char dob[15];
char bg[5];
char sex[10];
public :
virtual void read()
{
cout<<"\nEnter the name: ";
gets(name);
cout<<"Enter the Address: ";
gets(address);
cout<<"Enter date of birth (eg:28 5 1990) : ";
gets(dob);
cout<<"Enter the sex (Male / Female) : ";
cin>>sex;
cout<<"Enter the blood group: ";
cin>>bg;
}
virtual void disp()
{
cout<<"\nName: ";
puts(name);
cout<<"Address: ";
puts(address);
cout<<"Date of birth : "<<dob;
cout<<"\nsex : "<<sex;
cout<<"\nBlood group : "<<bg;
}
}pr[10];
class student : public personal
{
private :
char branch[20];
int sem;
char rollno[25];
int pcnt[8];
int ad_no;
int year;
public :
void read();
void edit(char[]);
void disp();
void show(int);
}s[10];
void student :: read()
{
cout<<"Enter the branch: ";
gets(branch);
cout<<"Enter the Semester: ";
cin>>sem;
cout<<"Enter the admission number : ";
cin>>ad_no;
cout<<"Enter the year of admission : ";
cin>>year;
cout<<"Enter the roll no: ";
cin>>rollno;
if(sem>3)
{
cout<<"Enter the percentage of marks in semseters published: ";
for(int i=0;i<sem-2;i++)
{
cin>>pcnt[i];
}
}
}
void student :: edit(char a[])
{
student *ptr2;
ptr2=s;
for(int i=0;i<n;i++)
{
if(strcmp((ptr2+i)->rollno,a)==0)
{
(ptr2+i)->sem++;
cout<<"\nEnter the percentage in Sem"<<(ptr2+i)->sem-2;
cin>>(ptr2+i)->pcnt[sem-3];
}
}
}
void student :: show(int d)
{
int a;
personal *ptr1;
student *ptr2;
ptr1=pr;
ptr2=s;
cout<<"DETAILS OF STUDENT ADMITTED IN THE YEAR "<<d<<"\n";
for(int i=0;i<n;i++)
{
if((ptr2+i)->year==d)
{
(ptr1+i)->disp();
}
}
}
void student :: disp()
{
int i;
cout<<"\nBranch : ";
puts(branch);
cout<<"Admission number : "<<ad_no;
cout<<"\nYear of admission : "<<year;
cout<<"\nSemester: "<<sem;
cout<<"\nRoll no: "<<rollno;
if(sem>3)
{
cout<<"\nPercentage of marks in semseters published: ";
for(i=0;i<sem-2;i++)
{
cout<<" "<<pcnt[i];
}
}
}
void main()
{
clrscr();
int c,d;
char a[25];
char ch;
personal *ptr1;
student *ptr2;
ptr1=pr;
ptr2=s;
cout<<"Enter the number of students: ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"Enter the details of student "<<i+1;
(ptr1+i)->read();
(ptr2+i)->read();
}
do
{
clrscr();
cout<<"\t\t\t MAIN MENU \t\n";
cout<<"1.Add Student\n";
cout<<"2.Edit Details\n";
cout<<"3.Details of students admitted in a particular year\n";
cout<<"4.Details of all students\n";
cout<<"5.Exit\n\n";
cout<<"Enter your choice: ";
cin>>c;
switch(c)
{
case 1:clrscr();
(ptr1+n)->read();
(ptr2+n)->read();
cout<<"\nStudent details added";
n++;
break;
case 2:clrscr();
cout<<"\nEnter the roll no: ";
cin>>a;
ptr2->edit(a);
cout<<"\nStudent details have been edited ";
break;
case 3:clrscr();
cout<<"\nEnter the year of admission : ";
cin>>d;
ptr2->show(d);
break;
case 4:clrscr();
for(int i=0;i<n;i++)
{
cout<<"\n\nThe details of student "<<i+1<<"\n";
(ptr1+i)->disp();
(ptr2+i)->disp();
}
break;
case 5:exit(0);
default:cout<<"\nWrong Choice";
}
getch();
}
while(c!=100);
}
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<process.h>
#include<stdio.h>
int n,m;
class pesonal
{
protected:
char name[30];
char address[80];
char dob[15];
};
class student:public personal
{
private:
char reg_no[10];
char doj[15];
char depart[30];
public:
void read();
void display();
friend void show(char[]);
}s[10];
void student :: read()
{
cout<<"Enter name : ";
gets(name);
cout<<"Enter address : ";
gets(address);
cout<<"Enter date of birth (eg:28 12 1990) : ";
gets(dob);
cout<<"Enter register number : ";
gets(reg_no);
cout<<"Enter date of join (eg:28 12 1990) : ";
gets(doj);
cout<<"Enter department : ";
gets(depart);
}
void student :: display()
{
cout<<"Name : "<<name;
cout<<"Address : "<<address;
cout<<"Date of birth : "<<dob;
cout<<"Register number : "<<reg_no;
cout<<"Date of join : "<<doj;
cout<<"Department : "<<depart;
}
class faculty : public personal
{
private:
char depart[30];
char doj[15];
char qualificaion[30];
int experiance;
int paper;
public:
void read();
void display();
friend void show(char[]);
}f[10];
void faculty :: read()
{
cout<<"Enter name : ";
gets(name);
cout<<"Enter address : ";
gets(address);
cout<<"Enter date of birth (eg:28 12 1990) : ";
gets(dob);
cout<<"Enter qualification of faculty : ";
gets(qualificaion);
cout<<"Enter year of experiance : ";
cin>>experiance;
cout<<"Enter the number of papers published : ";
cin>>paper;
cout<<"Enter date of join (eg:28 12 1990) : ";
gets(doj);
cout<<"Enter department : ";
gets(depart);
}
void faculty :: display()
{
cout<<"Name : "<<name;
cout<<"Address : "<<address;
cout<<"Date of birth : "<<dob;
cout<<"Date of join : "<<doj;
cout<<"Department : "<<depart;
cout<<"Qualification : "<<qualificaion;
cout<<"Experiance : "<<experiance;
cout<<"Number of papers published : "<<paper;
}
void show(char a[])
{
cout<<"FACULTY";
for(int i=0;i<n;i++)
{
if(strcmp(a,f[i].depart)==0)
{
cout<<i+1<<". "<<f[i].name;
}
}
cout<<"STUDENTS";
for(i=0;i<m;i++)
{
if(strcmp(a,s[i].depart)==0)
{
cout<<i+1<<". "<<s[i].name;
}
}
}
void main()
{
clrscr();
int c;
char l[30];
cout<<"Enter the number of faculties ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"Enter the details of faculty "<<i+1;
s[i].read();
clrscr();
}
cout<<"Enter the number of students ";
cin>>m;
for(i=0;i<m;i++)
{
cout<<"Enter the details of student "<<i+1;
s[i].read();
clrscr();
}
do
{
clrscr();
cout<<"\n\n\t\tMAIN
MENU\n\n\t1.Add a new faculty\n\t2.Add a new student\n\t3.Display the
members of a department\n\t4.Display all faculty details\n\t5.Display
all student details\n\t6.Exit\n\n\tEnter your choice : ";
cin>>c;
switch(c)
{
case 1:clrscr();
f[n].read();
n++;
cout<<"New faculty is added successfully ";
break;
case 2:clrscr();
s[m].read();
m++;
cout<<"New student is added successfully ";
break;
case 3:clrscr();
cout<<"Enter the name of department : ";
cin>>l;
show(l);
break;
case 4:clrscr();
cout<<"FACULTY DETAILS";
for(i=0;i<n;i++)
f[i].display();
break;
case 5:clrscr();
cout<<"STUDENT DETAILS";
for(i=0;i<m;i++)
s[i].display();
break;
case 6:exit(0);
default:cout<<"Enter the correct choice!!!!!!!";
}
getch();
}
while(c==c);
}
prog 4
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<process.h>
#include<stdio.h>
int n;
class student
{
protected:
char name[30];
char dob[15];
char reg_no[10];
char doj[15];
char depart[30];
};
class family
{
protected:
char father[30];
char mother[30];
char father_occup[30];
char mother_occup[30];
char address[50];
char ph_no[30];
char guardian[30];
};
class pta : student,family
{
private:
char id[10];
int amount;
char attended[15];
int no;
public:
void read();
void edit(char[]);
void display();
void show();
}s[10];
void pta :: read()
{
cout<<"\nEnter name : ";
gets(name);
cout<<"Enter address : ";
gets(address);
cout<<"Enter date of birth (eg:28 12 1990) : ";
gets(dob);
cout<<"Enter register number : ";
gets(reg_no);
cout<<"Enter date of join (eg:28 12 1990) : ";
gets(doj);
cout<<"Enter department : ";
gets(depart);
cout<<"Enter father name : ";
gets(father);
cout<<"Enter mother name : ";
gets(mother);
cout<<"Enter occupation of father : ";
gets(father_occup);
cout<<"Enter occupation of mother : ";
gets(mother_occup);
cout<<"Enter phone number : ";
cin>>ph_no;
cout<<"Enter name of guardian : ";
cin>>guardian;
cout<<"Enter pta id : ";
cin>>id;
cout<<"Enter pta fund amount : ";
cin>>amount;
cout<<"Enter date of last pta meeting attended : ";
gets(attended);
cout<<"Enter the number of pta meeting attended : ";
cin>>no;
}
void pta::display()
{
cout<<"\nName : "<<name;
cout<<"\nAddress : "<<address;
cout<<"\nDate of birth : "<<dob;
cout<<"\nRegister number : "<<reg_no;
cout<<"\nDate of join : "<<doj;
cout<<"\nDepartment : "<<depart;
cout<<"\nFather name : "<<father;
cout<<"\nMother name : "<<mother;
cout<<"\nOccupation of father : "<<father_occup;
cout<<"\nOccupation of mother : "<<mother_occup;
cout<<"\nPhone number : "<<ph_no;
cout<<"\nGuardian : "<<guardian;
cout<<"\nPta id : "<<id;
cout<<"\nPta fund amount : "<<amount;
cout<<"\nDate of last pta meeting attended : "<<attended;
cout<<"\nNo of pta meeting attended : "<<no;
}
void pta::show()
{
for(int i=0;i<n;i++)
{
if(s[i].no<=2)
{
cout<<"\nName : "<<s[i].name;
cout<<"\nAddress : "<<s[i].address;
cout<<"\nDate of birth : "<<s[i].dob;
cout<<"\nRegister number : "<<s[i].reg_no;
cout<<"\nDate of join : "<<s[i].doj;
cout<<"\nDepartment : "<<s[i].depart;
cout<<"\nFather name : "<<s[i].father;
cout<<"\nMother name : "<<s[i].mother;
cout<<"\nOccupation of father : "<<s[i].father_occup;
cout<<"\nOccupation of mother : "<<s[i].mother_occup;
cout<<"\nPhone number : "<<s[i].ph_no;
cout<<"\nGuardian : "<<s[i].guardian;
}
}
}
void pta::edit(char a[10])
{
for(int i=0;i<n;i++)
{
if(strcmp(s[i].id,a)==0)
{
s[i].read();
}
}
}
void main()
{
clrscr();
int c;
char l[30];
cout<<"Enter the number of students ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"Enter the details of student "<<i+1;
s[i].read();
clrscr();
}
do
{
clrscr();
cout<<"\n\n\t\tMAIN
MENU\n\n\t1.Add a new student\n\t2.Edit a student detail\n\t3.Display
deails of sudents attended atleast 2 meetings\n\t4.Display all student
details\n\t5.Exit\n\n\tEnter your choice : ";
cin>>c;
switch(c)
{
case 1:clrscr();
s[n].read();
n++;
cout<<"New student is added successfully ";
break;
case 2:clrscr();
cout<<"Enter the pta id : ";
cin>>l;
s[0].edit(l);
break;
case 3:clrscr();
s[0].show();
break;
case 4:clrscr();
cout<<"\t\tSTUDENT DETAILS\n\n";
for(i=0;i<n;i++)
s[i].display();
break;
case 5:exit(0);
default:cout<<"Enter the correct choice!!!!!!!";
}
getch();
}
while(c==c);
}
No comments:
Post a Comment