You are on page 1of 18

/*Bubble Sort*/

#include<iostream.h>
#include<conio.h>
void main()
{
int a[10],i,j,k,t;
clrscr();
cout<<"Enter 10 Numbers to sort :";
for(i=0;i<10;i++)
cin>>a[i];
cout<<"Array Elements :"<<endl;
for(i=0;i<10;i++)
cout<<a[i]<<"\t";
for(k=1;k<10;k++)
{
for(j=0;j<10-k;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
cout<<"Sorted Array :"<<endl;
for(i=0;i<10;i++)
cout<<a[i]<<"\t";
getch();
}

OUTPUT:

/*Scope of constructor and destructor */


#include<iostream.h>
#include<conio.h>
class Ratio
{
public:
void print()
{
cout<<"\nNow X is ALIVE"<<endl;
}
Ratio()
{
cout<<"OBJECT IS BORN"<<endl;
}
~Ratio()
{
cout<<"OBJECT DIES";
}
};

void main()
{
clrscr();
Ratio r1;
r1.print();
getch();
}
Output:

/*Swap two numbers using pointers*/

#include<iostream.h>
#include<conio.h>
void swap(int *,int *);
void main()
{
int n1,n2;
clrscr();
cout<<"Enter Number 1 :";
cin>>n1;
cout<<"Enter Number 2 :";
cin>>n2;
cout<<"Numbers before swapping :"<<n1<<"\t"<<n2<<endl;
swap(&n1,&n2);
cout<<"Numbers after swapping :"<<n1<<"\t"<<n2<<endl;
getch();

}
void swap(int *x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}

OUTPUT:

/*Binary Search*/

#include<iostream.h>
#include<conio.h>
int binsearch(int [],int); //function prototype
void main()
{
int a[10],i,j,k,t,s,loc;
clrscr();
cout<<"Enter 10 array elements:"<<endl;
for(i=0;i<10;i++)
cin>>a[i];
cout<<"Array Elements :"<<endl;
for(i=0;i<10;i++)
cout<<a[i]<<"\t";

for(k=1;k<10;k++)
{
for(j=0;j<10-k;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
cout<<"Sorted Array :"<<endl;
for(i=0;i<10;i++)
cout<<a[i]<<"\t";

cout<<"Enter Number to search :";


cin>>s;
loc=binsearch(a,s);
if(loc==-1)
cout<<"Number not found";
else
cout<<"Number found at position :"<<loc+1;
getch();
}
int binsearch(int a[],int no)
{
int low=0,mid,high=9;
while(low<=high)
{
mid=(low+high)/2;
if(no==a[mid])
return mid;
if(no<a[mid])
high=mid-1;
else
low=mid+1;
}
return -1;
}

OUTPUT:

/* Implementing class circle with default constructor and accessing member functions like area and
circumference*/

#include<iostream.h>
#include<conio.h>
class circle
{
private:
float rad,x,y;
public:
circle() //default constructor
{
rad=0;
x=0;
y=0;
}
void getdata()
{
cout<<"Enter x-coord and y-coord of center point :";
cin>>x>>y;
cout<<"Enter radius :";
cin>>rad;
}
void area()
{
float ar;
ar=3.14*rad*rad;
cout<<"Area :"<<ar<<endl;
}
void circumference()
{
cout<<"Circumference :"<<2*3.14*rad<<endl;
}
};

void main()
{
clrscr();
circle o; OUTPUT:
o.getdata();
o.area();
o.circumference();
getch();
}

/* Overloading + and / operator */

#include<iostream.h>
#include<conio.h>
class Ratio
{
int num,den;
public:
void get()
{
cin>>num>>den;
}
void show()
{
cout<<num<<"/"<<den<<endl;
}
Ratio operator +(Ratio r)
{
//o1.operator(o2)
Ratio t;
if(den==r.den)
{
t.num=num+r.num;
t.den=den;
}
else
{
t.num=num*r.den+r.num*den;
t.den=den*r.den;
}
return t;
}
Ratio operator /(Ratio r)
{
Ratio t;
t.num=num*r.den;
t.den=den*r.num;
return t;
}
};
void main()
{
clrscr();
Ratio o1,o2,o3;
cout<<"Enter Num and Den of Ratio 1 :";
o1.get();
cout<<"Ratio 1:";
o1.show();
cout<<"Enter Num and Den of Ratio 2 :";
o2.get();
cout<<"Ratio 2:";
o2.show();
o3=o1+o2; //o1.operator +(o2)
cout<<"Addition of 2 ratios :";
o3.show();
cout<<"Division of 2 ratios :";
o3=o1/o2; //o1.operator /(o2)
o3.show();
getch();
}

OUTPUT:

/*Implementing class ratio with member functions like assign, convert and invert */

#include<iostream.h>
#include<conio.h>
class ratio
{
public:
void assign(int, int);
double convert();
void invert();
void print();
private:
int num, den;
};
void main()
{
ratio x;
x.assign(22,7);
clrscr();
cout<<"x=";
x.print();
cout<<"="<<x.convert()<<"\n";
x.invert();
cout<<"1/x=";
x.print();
cout<<"\n";
getch();
}
void ratio::assign(int numerator, int denominator)
{
num=numerator;
den=denominator;
}
double ratio::convert()
{
return (double)num/den;
}
void ratio::invert()
{
int temp=num;
num=den;
den=temp;
}

void ratio::print()
{
cout<<num<<"/"<<den;
}
OUTPUT:
/*Implementing Inheritance */

#include<iostream.h>
#include<conio.h>
class student
{
protected:
int roll;
char name[20];
public:
void getinfo()
{
cout<<"Enter rollno and name :";
cin>>roll>>name;
}
void showinfo()
{
cout<<"Roll No :"<<roll<<endl;
cout<<"Name :"<<name<<endl;
}
};
class test : public student
{
protected:
int m1,m2;
public:
void getmarks()
{
cout<<"Enter marks of Subject 1:";
cin>>m1;
cout<<"Enter marks of Subject 2:";
cin>>m2;
}
void showmarks()
{
cout<<"Subject 1 Marks :"<<m1<<endl;
cout<<"Subject 2 Marks :"<<m2<<endl;
}

};
class sports
{
protected:
int spmarks;
public:
void getsports()
{
cout<<"Enter Sports marks :";
cin>>spmarks;
}
void showsports()
{
cout<<"Sports Marks :"<<spmarks<<endl;
}
};
class result : public test, public sports
{
int total,per;
public:
void calculate()
{
total=m1+m2+spmarks;
per=total/3;
}
void showresult()
{
cout<<"Total Marks :"<<total<<endl;
cout<<"Percentage :"<<per;
}
};

void main() OUTPUT:

clrscr();

result s;
s.getinfo();
s.getmarks();
s.getsports();
s.calculate();
s.showinfo();
s.showmarks();
s.showsports();
s.showresult();
getch();
}

/*Using Virtual Function*/

#include<iostream.h>
#include<conio.h>
class Person
{
public:
virtual void print()
{
cout<<"Name of person :BOB"<<endl;
}

};
class Student : public Person
{

public:
void print()
{
cout<<"Name of student :TOM";
}
};
void main()
{
clrscr();
Person *p,p1;
p=&p1;
p->print();

Student s1;
p=&s1;
p->print();
getch();
}

OUTPUT:

/*File Handling*/
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
void main()
{
ifstream fcountry;
ifstream fcapital;
char fnm1[20],fnm2[20],str1[20],str2[20];
clrscr();
cout<<"\nEnter country filename-";
cin>>fnm1;
fcountry.open(fnm1);
if(!fcountry)
cout<<"\n Country file not found";
else
{
cout<<"\nEnter capital filename-";
cin>>fnm2;
fcapital.open(fnm2);
if(!fcapital)
cout<<"\n Capital file not found";
else
{
while(!fcountry.eof())
{
fcountry.getline(str1,20,'\n');
cout<<str1<<"\t";
fcapital.getline(str2,20,'\n');
cout<<str2<<endl;
}
}
}
fcapital.close();
fcountry.close();
getch();
}
OUTPUT:

HTML PROGRAM

<html>

<title>My Web Page</title>

<body bgcolor="pink">

<h2><marquee>welcome to my page</marquee></h2>

<br></br>

<table border="1">

<tr><td colspan="2">Computer Science</td>

<td colspan="2">Chemistry</td>

<td colspan="2">Physics</td></tr>

<tr><td>Theory</td>

<td>Pracs</td>

<td>Theory</td>

<td>Pracs</td>

<td>Theory</td>

<td>Pracs</td></tr>

<tr><td>80</td>
<td>60</td>

<td>50</td>

<td>80</td>

<td>70</td>

<td>59</td></tr>

<tr><td>50</td>

<td>60</td>

<td>35</td>

<td>47</td>

<td>75</td>

<td>46</td></tr>

</table>

<br></br>

<A href="http://www.vidyavalleynp.in/"><img src="C:\Users\Public\Pictures\Sample Pictures\


Chrysanthemum.jpg"

alt="picture file" width=200 height=200></img></a>

</body>
</html>

# FILE NAME : binsoft.html

# CODE

<html>

<head>

<title>Binsoft.com</title>

</head>

<body bgcolor="#d6fa98">
<h1 align="center" style="color:green">BINSOFT</h1>

<hr>

<p><font color="red">Welcome to Binsoft Pvt. Ltd. one of the most leading companies
in the sofware industries.One of the foremost companies in this industry with over 25 years of
Experience</font></p>

<p><font color="green">Our Softwares include a variety of uses like Pagers,Pay


roll,AIML etc.Our work in AI and ML has made an remarkable progess in the world helping many
SME,Enterprises in their requirements</font></p>

<p><font color="blue">Leading company with leading clients in computer


industries.With over 25 Years of expirence with most languages as PHP,Python,Ruby,Java etc and
developed many applications as per the need of our clients</font></p>

<a href="C:/Users/Admin/OneDrive/Documents/client.html">Click Here to know our


clients</a>

<hr>

<h2>Contact Us To Know more </h2>

<p><b>Tel.</b> <a href="tel:09999999999">099999999</a></p>

<p><b>Email.</b> <a
href="mailto:support@binsoft.com">support@binsoft.com</a></p>

<p><b>Addr.</b> Binsoft Softwares Pvt. Ltd. Ganesh Arcade Floor 3,4 Pune,411011</p>

<hr>

</body>

</html>

# FILE NAME : client.html

# CODE

<html>

<head>

<title>Binsoft Clients</title>

</head>
<body bgcolor="#d6fa98">

<h1 align="center"><font color="green">BINSOFT</font></h1>

<h2 align="center"><font color="green">Our Clients</font></h2>

<p align="center" ><a href=" binsoft.html ">Home</a></p>

<hr>

<ol>

<li>ABS Enginnerings</li>

<li>RL Advanced Enginnerings</li>

<li>RD Techsoft</li>

<li>Techfins</li>

<li>FinMines</li>

<li>RS Logistics</li>

</ol>

<hr>

</body>

</html>

You might also like