Computer Science-1 Printout
Computer Science-1 Printout
Name –
************************************************************************
#include<iostream.h>
#include<conio.h>
void swap(float&x , float&y)
{
float t=x;
x=y;
y=t;
}
void main()
{
clrscr();
float a,b;
cout<<”Value of a & b before swapping : ”<<endl;
cout<<"Enter value of a and b " <<endl;
cin>>a>>b;
swap(a,b);
cout<<”Value of a & b after swapping : ”<<endl;
cout<<"a ="<<a<<endl<<"b= "<<b<<endl;
getch();
}
************************************************************************
OUTPUT:
************************************************************************
************************************************************************
#include<iostream.h>
#include<conio.h>
void main()
{
Clrscr();
float a[10], p;
int i, top, bot, mid;
cout<<"Type the number in ascending order"<<endl;
for (i=0;i<10; i++)
{
cin>>a [i];
}
top=0;
bot=9;
cout<<"Type the no. you want to search"<<endl;
cin>>p;
mid= (top+bot) /2;
while( (top<=bot) && (a [mid] ! =p))
{
if (p<a [mid] )
bot=mid-1;
else
top=mid+1;
mid= (top+bot) /2;
}
if (a [mid] ==p)
{
cout<<"The number is at position : "<< (mid+1) <<endl;
}
else
cout<<"The number is not found"<<endl;
getch();
}
************************************************************************
OUTPUT:
************************************************************************
************************************************************************
#include<iostream.h>
#include<conio.h>
class circle
{
private:
float x,y,r;
float a,c;
public:
void assign();
void area();
void circum();
void print ();
};
void circle::assign()
{
cout<<"Type the x and y coordinates of the center = "<<endl;
cin>>x>>y;
cout<<"Type the radius = ";
cin>>r;
}
void circle::area()
{ a=3.14*r*r;
}
void circle::circum()
{
c=2*3.14*r;
}
void circle::print()
{
cout<<"x co-ordinate = "<<x<<endl<<"y co-cordinate = "<<y<<endl;
cout<<"The radius is = "<<r<<endl;
cout<<"The area is = "<<a<<endl;
cout<<"The circumference is = "<<c<<endl;
}
void main()
{
clrscr();
circle c;
c.assign();
c.area();
c.circum();
c.print();
getch();
}
************************************************************************
OUTPUT:
************************************************************************
void main()
{
clrscr();
ratio x;
x.assign (22,7);
cout<<x.convert()<<endl;
x.invert();
cout<<"1/x= "
x.print();
cout<<endl;
}
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<<"Reciprocal= "<<num<<"/
"<<den;
getch();
}
************************************************************************
OUTPUT:
Num/den = 22/7 = 3
1/x = 7/22
Exp – 5
Name -
************************************************************************
#include<iostream. h>
#include<conio .h>
class ratio
{
public:
ratio()
{
cout<<"Object is born "<<endl;
}
~ratio()
{
cout<<"Object dies "<<endl ;
}
};
void main ()
{
ratio n;
cout<<"now n is active "<<endl;
cout<<"at the end of the program "<<endl;
}
************************************************************************
OUTPUT :
************************************************************************
Object is born
now n is active
at the end of program
Object dies
Exp – 6
Name -
************************************************************************
#include<iostream.h>
#include<conio.h>
class complex
{
float x,y;
public:
complex(){}
complex(float real,float img)
{
x=real;
y=img;
}
complex operator+(complex);
void display(void);
};
complex complex::operator+(complex c)
{
complex t;
t.x=x+c.x;
t.y=y+c.y;
return(t);
}
void complex::display(void)
{
cout<<x<<"+j"<<y<<"\n";
}
void main()
{
clrscr();
complex c1,c2,c3;
c1=complex(2.5,3.5);
c2=complex(1.6,2.7);
c3=c1+c2;
cout<<"c1=";
c1.display();
cout<<"c2=";
c2.display();
cout<<"c3=";
c3.display();
getch();
}
OUTPUT :
************************************************************************
c1=2.5+j3.5
c2=1.6+j2.7
c3=4.1+j6.2
Exp – 7
Name -
************************************************************************
#include<iostream.h>
#include<conio.h>
class ratio
{
float x,y;
public: ratio(){}
ratio(float p ,float q)
{
x=p;
y=q;
}
ratio operator +(ratio);
ratio operator /(ratio);
void display(void);
};
ratio ratio:: operator +(ratio c)
{
ratio t;
t.x=x+c.x;
t.y=y+c.y;
return(t);
}
ratio ratio:: operator/(ratio c)
{
ratio t;
t.x=x/c.x;
t.y=y/c.y;
return (t);
}
void ratio:: display(void)
{
cout<<"X="<<x<<"\t"<<"Y="<<y;
}
void main ()
{
clrscr();
ratio r1,r2,r3,r4;
r1=ratio(2.5,3.5);
r2=ratio(1.6,2.9);
r3=r1+r2;
r4=r1/r2;
cout<<"r1=";r1.display();cout<<"\n";
cout<<"r2=";r2.display();cout<<"\n";
cout<<"r3=";r3.display();cout<<"\n";
cout<<"r4=";r4.display();
getch();
}
OUTPUT :
************************************************************************
r1=X=2.5 Y=3.5
r2=X=1.6 Y=2.9
r3=X=4.1 Y=6.4
r4=X=1.5625 Y=1.206897
Exp – 8
Name -
************************************************************************
#include<iostream.h>
#include<conio.h>
class student
{
int roll_no;
public:
void get_no(int a)
{
roll_no=a;
}
void put_no(void)
{
cout<<"roll_no:0"<<roll_no<<endl;
}
};
class test:public student
{
public:
float s1,s2;
public:
void get_marks(float x,float y)
{
s1=x;
s2=y;
}
void put_marks(void)
{
cout<<"marks obtained:"<<endl<<"s1="<<s1<<endl<<"s2="<<s2<<endl;
}
};
class sports
{
public:
int score;
void get_score(int x)
{
score=x;
}
void put_score(void)
{
cout<<"sports marks: "<<score<<endl;
}
};
class result :public test , public sports
{
float tot;
public:
void display(void)
{
tot=s1+s2+score;
put_no();
put_marks();
put_score();
cout<<"total score="<<tot;
}
};
void main()
{
clrscr();
result st1;
st1.get_no(101);
st1.get_marks(39,65);
st1.get_score(29);
st1.display();
getch();
}
************************************************************************
OUTPUT :
************************************************************************
roll_no : 0101
Marks obtained :
S1 = 39
S2 = 65
Sports marks : 289
Total score = 133
Exp – 9
Name -
************************************************************************
#include<iostream.h>
#include<conio.h>
#include<string.h>
class person
{
public:
person(char *s)
{
name=new char[strlen(s+1)];
strcpy(name,s);
}
void print()
{
cout<<"My name is:" <<name;
}
protected:
char *name;
};
class student:public person
{
float rno;
public:
student(char *s,float r):person(s),rno(r)
{
}
void print()
{
cout<<"My name is:" <<name<<" "<<"My roll no is: "<<rno;
}
};
void main()
{
person *p;
person x("BOB");
p=&x;
p->print();
student y("TOM",101);
p=&y;
p->print();
getch();
}
************************************************************************
OUTPUT :
My name is BOB My name is TOM
Exp – 10
Name -
************************************************************************
#include<string.h>
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"\n Enter String :-";
char s[50],temp;
cin.get(s,50);
int len=strlen(s);
int l=len-1;
for(int i=0;i<len/2;i++)
{
temp=s[i];
s[i]=s[l];
s[l]=temp;
l--;
}
cout<<"\n Reverse of string is :-"<<s;
getch();
}
************************************************************************
OUTPUT :
************************************************************************
Binary_soft.html OUTPUT
Clients.html OUTPUT
Exp – 12
Name -
************************************************************************
page1.html
<HTML>
<HEAD>
<TITLE>MY WEB PAGE 1</TITLE>
<BODY BGCOLOR="AQUA">
<H1><CENTER><U>Abhishek Jr.College</U></CENTER></H1>
<BR>
<H2><marquee><font color="RED">SCIENCE STREAM
</font></marquee></H2>
<TABLE BGCOLOR="YELLOW" ALIGN="CENTER" WIDTH="7"
HEIGHT="5" BORDER="1" CELLSPACING="3" CELLPADDING="4">
<CAPTION><H3><U>DISTRIBUTION OF MARKS</U></H3></CAPTION>
<TR>
<TD COLSPAN="3">COMPUTER SCIENCE</TD>
<TD COLSPAN="3">CHEMISTRY</TD>
<TD COLSPAN="3">PHYSICS</TD>
</TR>
<TR>
<TD>THEORY</TD>
<TD>PRACTICAL</TD>
<TD>ORAL</TD>
<TD>THEORY</TD>
<TD>PRACTICAL</TD>
<TD>ORAL</TD>
<TD>THEORY</TD>
<TD>PRACTICAL</TD>
<TD>ORAL</TD>
</TR>
<TR>
<TD>95</TD>
<TD>85</TD>
<TD>75</TD>
<TD>95</TD>
<TD>85</TD>
<TD>75</TD>
<TD>95</TD>
<TD> 85 </TD>
<TD> 75 </TD></TR>
<TR>
<TD> 55 </TD>
<TD > 65 </TD>
<TD> 55 </TD>
<TD> 45 </TD>
<TD> 65 </TD>
<TD> 55 </TD>
<TD> 45 </TD>
<TD> 95 </TD>
<TD> 75 </TD>
</TR>
<TR>
<TD> 35 </TD>
<TD> 25 </ TD>
<TD> 15 </TD>
<TD> 35 </TD>
<TD > 25 </TD>
<TD > 15 </TD>
<TD > 35 </TD>
<TD > 25 </TD>
<TD>15</TD>
</TR>
</TABLE>
<BR><BR >
<A HREF="C:\Users\College100\Desktop\page2.html">
<CENTER>
<IMG SRC="C:\Users\College100\Desktop\AJC.jpg" WIDHT =" 400 "
HEIGHT="200">
</CENTER>
</IMG>
</A>
</BODY>
</HTML>
Page2.html
<HTML>
<BODY BGCOLOR="AQUA">
<H1><CENTER>DISTRIBUTION OF MARKS</CENTER></H1>
<TABLE BGCOLOR "YELLOW" ALIGN="CENTER" WIDTH="7"
HEIGHT="5" BORDER="1" CELLSPACING="3" CELLPADDING="4">
<CAPTION><H3><U>OPTIONAL SUBJECTS</U></H3></CAPTION>
<TR>
<TD COLSPAN="2">HINDI</TD>
<TD COLSPAN="2">GERMAN</TD>
<TD COLSPAN="2">MARATHI</TD>
<TD COLSPAN="1">TOTAL</TD>
</TR>
<TR>
<TD>THEORY</TD>
<TD>ORAL</TD>
<TD>THEORY</TD>
<TD>ORAL</TD>
<TD>THEORY</TD>
<TD>ORAL</TD>
<TD></TD>
<TR>
<TD>90</TD>
<TD>80</TD>
<TD>70</TD>
<TD>90</TD>
<TD>80</TD>
<TD>70</TD>
<TD>90</TD>
</TR>
<TR>
<TD>60</TD>
<TD>50</TD>
<TD>40</TD>
<TD>60</TD>
<TD>50</TD>
<TD>40</TD>
<TD>60</TD>
</TR>
<BR><BR>
<TABLE BGCOLOR="YELLOW" ALIGN="CENTER" WIDTH="7" HEIGHT="5"
BORDER="1" CELLSPACING="3" CELLPADDING="4">
<CAPTION><H1><U>BIFOCAL SUBJECTS</U></H3></CAPTION><BR>
<TR>
<TD COLSPAN="3">CS</TD>
<TD COLSPAN="3">ELECTRONICS</TD>
</TR>
<TR>
<TD>THEORY</TD>
<TD>PRACTICAL</TD>
<TD>ORAL</TD>
<TD>THEORY</TD>
<TD>PRACTICAL</TD>
<TD>ORAL</TD>
</TR>
<TR>
<TD>90</TD>
<TD>80</TD>
<TD>70</TD>
<TD>90</TD>
<TD>80</TD>
<TD>70</TD>
</TR>
<TR>
<TD>60</TD>
<TD>50</TD>
<TD>40</TD>
<TD>60</TD>
<TD>60</TD>
<TD>70</TD>
</TR>
</BODY>
</HTML>
Page1.html OUTPUT
Page2.html OUTPUT
Exp – 13
Name -
************************************************************************