Professional Documents
Culture Documents
Print File 12th Cs 22 23
Print File 12th Cs 22 23
#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:
void main()
{
clrscr();
Ratio r1;
r1.print();
getch();
}
Output:
#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";
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();
}
#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;
}
};
clrscr();
result s;
s.getinfo();
s.getmarks();
s.getsports();
s.calculate();
s.showinfo();
s.showmarks();
s.showsports();
s.showresult();
getch();
}
#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>
<body bgcolor="pink">
<h2><marquee>welcome to my page</marquee></h2>
<br></br>
<table border="1">
<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>
</body>
</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>
<hr>
<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>
# CODE
<html>
<head>
<title>Binsoft Clients</title>
</head>
<body bgcolor="#d6fa98">
<hr>
<ol>
<li>ABS Enginnerings</li>
<li>RD Techsoft</li>
<li>Techfins</li>
<li>FinMines</li>
<li>RS Logistics</li>
</ol>
<hr>
</body>
</html>