II PUC LAB
II PUC LAB
void Insertion::Getdata()
{
cout<<"\nENTER ARRAY LIMITS:";
cin>>N;
cout<<"\nENTER"<<N<<"ARRAY ELEMENTS\n";
for(I=0;I<=N-1;I++)
{
cin>>A[I];
}
}
void Insertion::Putdata()
{
cout<<"\nENTER POSITION:";
cin>>P;
if(P<=N-1)
{
cout<<"\nENTER ELEMENTS TO INSERT:";
cin>>ELE;
for(I=N-1;I>=P;I--)
{
A[I+1]=A[I];
}
A[P]=ELE;
N=N+1;
cout<<ELE<<"IS SUCCESSFULLY INSERTED\n";
cout<<"ARRAY ELEMENTS ARE \n";
for(I=0;I<=N-1;I++)
{
cout<<A[I]<<"\n";
}
}
else
{
cout<<"\nINVALID POSITION\n";
}
void main()
{
clrscr();
Insertion I;
I.Getdata();
I.Putdata();
getch();
}
else
{
cout<<"\nINVALID POSITION\n";
}
}
void main()
{
clrscr();
Deletion D;
D.Getdata();
D.Putdata();
getch();
}
C++ program to search for a given element in an array using Binary search method.
#include<iostream.h>
#include<conio.h>
class Binary
{
int A[10],LOC,N,ELE;
int BEG,END,MID;
public:
void Getdata();
void Search();
void Putdata();
};
void Binary::Getdata()
{
cout<<"\nENTER ARRAY LIMITS:";
cin>>N;
cout<<"\nENTER"<<N<<"ARRAY ELEMENTS\n";
for(int I=0;I<=N-1;I++)
{
cin>>A[I];
}
}
void Binary::Putdata()
{
int BEG,END,MID;
BEG=0,END=N-1,LOC=-1;
cout<<"\nENTER ELEMENT TO BE SEARCHED:";
cin>>ELE;
while(BEG<=END)
{
MID=int(BEG+END)/2;
if(ELE==A[MID])
{
LOC=MID;
break;
}
else
{
if(ELE<A[MID])
END=MID-1;
else
BEG=MID+1;
}
}
if(LOC>=0)
cout<<"\nELEMENT"<<ELE<<"FOUND AT LOCATION"<<LOC+1;
else
cout<<"\nELEMENT"<<ELE<<"NOT FOUND";
}
void main()
{
clrscr();
Binary B;
B.Getdata();
B.Putdata();
getch();
}
void main()
{
int X,N;
clrscr();
cout<<"\nENTER BASE(X) AND POWER VALUE:";
cin>>X>>N;
SeriesS1(X,N);
cout<<"\nSUM OF SERIES:"<<S1.Sumseries();
getch( );
}
C++ program to create base class and derived class to compute two subject marks using
single level inheritance.
#include<iostream.h>
#include<conio.h>
class Base
{
int ROLLNO;
char NAME[20];
public:
void Bgetdata()
{
cout<<"\nENTER STUDENT NAME AND ROLL NUMBER:";
cin>>NAME>>ROLLNO;
}
void Bputdata()
{
cout<<"\nSTUDENT NAME : "<<NAME;
cout<<"\nROLL NUMBER:"<<ROLLNO;
}
};
class Derived :public Base
{
int M1,M2, TOTAL;
public:
void Dgetdata()
{
cout<<"\nENTER SUB1 AND SUB2 MARKS:";
cin>>M1>>M2;
}
void Dputdata()
{
TOTAL = M1 + M2;
cout<<"\nSUBJECT 1 : "<<M1;
cout<<"\nSUBJECT 2 : "<<M2;
cout<<"\nTOTALMARKS:"<<TOTAL;
}
};
void main()
{
Derived D;
clrscr();
D.Bgetdata();
D.Dgetdata();
D.Bputdata();
D.Dputdata();
getch();
}
C++ program to read and display the data by creating a class using the concept of pointers
to objects.
#include<iostream.h>
#include<conio.h>
class Student
{
int REGNO;
char NAME[20];
float FEES;
public: void Getdata();
void Putdata();
};
void Student::Getdata()
{
cout<<"\nENTER STUDENT REGISTER NO,NAME AND FEES:";
cin>>REGNO>>NAME>>FEES;
}
void Student::Putdata()
{
cout<<"\nREGISTER NUMBER:"<<REGNO;
cout<<"\nSTUDENT NAME : "<<NAME;
cout<<"\nSTUDENT FEES : "<<FEES;
}
void main()
{
Student S,*SP;
SP=&S;
clrscr();
SP->Getdata();
SP->Putdata();
getch();
}
HTML program to create a study time-table.
<html>
<head>
<title>COLLEGE TIME TABLE</title>
</head>
<body bgcolor=PINK>
<center><h2>STUDY TIME TABLE</h2>
<table border=15 cellspacing=10 cellpadding=8>
<tr>
<th>DAY/ TIME</td>
<th><i>MORNING</i></th>
<th><i>EVENING</i></th>
</tr>
<tr>
<th>MON/THU</th>
<td>MAT/ACC </td>
<td>KAN/HIN </td>
</tr>
<tr>
<th>TUE/FRI</th>
<td>CHEM/BUS </td>
<td>ENGLISH</td>
</tr>
<tr>
<th>WED/SAT </th>
<td>PHY/ECO </td>
<td>COMP.SCI.</td>
</tr>
</table>
</center>
</body>
</html>