PRACTICAL NO:- 1
AIM:- Create a simple HTML page on any of the following topics :- College Profile, Computer
Manufacturer, or Software Development Company. The page must consist of at least 3
paragraphs of text. The page must have an appropriate title, background color or background
image, and hyperlinks to other pages. The paragraphs must have text consisting of different
colors and styles in terms of alignment and Font Size.
CODE:-
FIRST.HTML
<HTML><HEAD><TITLE>MY WEB PAGE</TITLE></HEAD>
<BODY BGCOLOR="yellow">
<H1><CENTER> NEW TECH PRIVATE LIMITED </CENTER><H1>
<P>
<FONT COLOR="Blue" SIZE="6" FACE="MONOTYPE CORSIVA">
One of the leading software company is New Tech Private Limited. It was established in the year 1998.
And since its inception, it has been growing day by day. Today it is one of the best Software
development company.
</FONT></P>
<P>
<FONT COLOR="green" SIZE="5" FACE="arial">
Working in IT is one of the world's most challenging jobs--- which is sometimes bad and sometimes
good. New Tech makes it possible to enjoy challenges.
</P>
<P>
<FONT COLOR="red" SIZE="3" FACE="Times new roman">
To get things done these days, working in teams is almost imperative.New Tech has a strong team with
motivating leaders which is the root cause why the company is touching the sky.
</FONT>
</P>
<A HREF="SECOND.HTML">CLICK HERE TO APPLY OF THE COMPANY</A></BODY></HTML>
SECOND .HTML
<HTML>
<BODY BGCOLOR=”Green”>
<MARQUEE>HELLO WORLD!!!</MARQUEE>
THIS IS THE SECOND FILE.
</BODY>
</HTML>
Output:
PRACTICAL NO:- 2
AIM:- Write a HTML Code with create a Table with 3 Columns and 4 Rows. The table must
have atleast one cell merged. The page must have image and image itself act like
hyperlink.When the mouse is placed on image, some message should be displayed.page must
have scrolling marquee.
Code:
THIRD.HTML
<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 colspan="2">Chemistry
<td colspan="2">Physics
</tr>
<tr><td>Theory
<td>Pracs
<td>Theory
<td>Pracs
<td>Theory
<td>Pracs
</tr>
<tr><td>80
<td>60
<td>50
<td>60
<td>80
<td>70</tr>
<tr><td>50
<td>60
<td>35
<td>4
<td>75
<td>46</tr>
</table><br><br>
<A HREF ="FIRST.html"><img src="Image.jpg" alt="picture file" width=200
height=200></A></Body></html>
output:
PRACTICAL NO:- 3
AIM:- Write a program in C++ that first initializes an array of given 10 real numbers. The
program must sort numbers in ascending/descending order using Bubble-Sort method. It should
print the given list of numbers before and after sorting of elements.
Code:
#include<iostream.h>
#include<conio.h>
void main()
int a[10],i,k,j,t;
clrscr();
cout<<"enter elements ";
for(i=0;i<10;i++)
cin>>a[i];
for(i=0;i<10;i++)
cout<<"the elements are "<<a[i]<<endl;
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<<"the sorted array ";
for(j=0;j<10;j++)
cout<<endl<<a[j];
getch();
OUTPUT:
PRACTICAL NO:- 4
AIM:- Write a function in C++ that exchanges data (passing by pointers) using swap function to
interchange the given two numbers
CODE:-
#include<iostream.h>
#include<conio.h>
#include<string.h>
void swap(int*p1,int *p2)
inttemp;
temp=*p1;
*p1=*p2;
*p2=temp;
void main()
clrscr();
int a,b;
cout<<"/n Enter two numbers :";
cin>>a>>b;
cout<<"\n numbers Before Swapping:";
cout<<"\n a="<<a;
cout<<"\n b="<<b;
swap(&a, &b);
cout<<"\n Numbers After Swapping:";
cout<<"\n a="<<a;
cout<<"\n b="<<b;
getch();
Output:
PRACTICAL NO:- 5
AIM:- Write a program in C++ to reverse a string without string function.
CODE:-
Reversing the String
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<string.h>
void main()
clrscr();
cout<<"\n Enter string\n";
char s[100],temp;
gets(s);
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 the string=\n"<<s;
getch();
}
Output:
PRACTICAL NO:- 6
AIM:- Write a program in C++ with a ratio class using member functions like assign ( )
function to initialize. Its member data (integer numerator and denominator), convert ( ) function
to convert the ratio into double, invert ( ) function to get the inverse of the ratio and print ( )
function to print the ratio and its reciprocal.
CODE:-
#include<iostream.h>
#include<conio.h>
class ratio
int num,den;
public:
void assign(int n,int d)
num=n;
den=d;
void convert();
void invert();
void print();
};
void ratio::convert()
cout<<"the ratio is "<<double(num)/double(den);
void ratio::invert()
{
int temp;
temp=num;
num=den;
den=temp;
void ratio::print()
cout<<"\n the values are"<<num<<"/"<<den<<"\n";
void main()
clrscr();
ratio r;
r.assign(22,7);
r.convert();
r.print();
r.invert();
cout<<"After invering the values";
r.print();
getch();
}
Output:
PRACTICAL NO:- 07
AIM:- Implement a derived class in C++. Each object of this class will represent a circle,
storing its radius ,x and y co-ordinates of its centre as floats. Include a default constructor, access
functions, an area ( ) function and a circumference ( ) function. The program must print the co-
ordinates with radius, area and circumference of the circle.
CODE:-
#include<iostream.h>
#include<conio.h>
class Circle
private:
float x,y;
float radius;
public:
Circle()
x=0.0;
y=0.0;
radius=0.0;
void getdet()
cout<<"\n enter x coordinates:",
cin>>x;
cout<<"\n Enter y coordinates:",
cin>>y;
cout<<"\n Enter radius:";
cin>>radius;
void area()
cout<<"\n Area="<<(3.14*radius*radius);
void circumference()
cout<<"\n circumference="<<(2*3.14*radius);
void print()
cout <<"\n Circle details are as follows::";
cout<<"\n \n X="<<x;
cout<<"\n Y="<<y;
cout<<"\n Radius="<<radius;
area();
circumference();
};
void main()
{
clrscr();
Circle obj;
obj.getdet();
obj.print();
getch();
Output:
PRACTICAL NO:- 08
AIM:- Write a program in C++ that initializes a Ratio class with no parameters as a default constructor.
The program must print the message “OBJECT IS BORN” during initialization. It should display the
message “NOW X IS ALIVE”, when the first member function Ratio x is called. The program must
display “OBJECT DIES” when the class destructor is called for the object when it reaches the end of its
scope.
CODE:-
#include<iostream.h>
#include<conio.h>
class Ratio
{
public:
Ratio()
{
cout<<"OBJECT IS BORN"<<endl;
}
void function()
{
cout<<"NOW X IS ALIVE:-"<<endl;
}
~Ratio()
{
cout<<"OBJECT DIES:-"<<endl;
}
};
void main()
{
clrscr();
Ratio X;
X.function();
getch();
}
Output:
PRACTICAL NO:- 09
AIM:- Write a program in C++ using virtual function. The function must declare P to be a
pointer to object of the base class Person. First, the program must assign p to point an instance
x(name of the person e.g. BOB) of class Person. The program must then assign p to point at an
instance y (name of the student e.g. TOM) of the derived class student. Define a print function in
the base class to print the name of the Person. The second call to the print function must print the
name of the student using derived class’s print function.
CODE:-
#include<iostream.h>
#include<conio.h>
class Person
public:
virtual void print()
cout<<"\n The Name of person is BOB";
};
class Student:public Person
public:
void print()
cout<<"\n The Name of the student is TOM";
}
};
void main()
clrscr();
Person *p;
Person p1;
p=&p1;
p->print();
Student s1;
p=&s1;
p->print();
getch();
Output:
PRACTICAL NO:- 10
AIM:- Write a program in C++ that first initializes an array of given 10 sorted real numbers.
The program must verify whether a given element belongs to this array or not, using Binary
Search technique. The element (to be searched) is to be entered at the time of execution. If the
number is found, the program should print its position in the array otherwise it should print. “The
number is not found”.
CODE:-
#include<iostream.h>
#include<conio.h>
#include<string.h>
int Bsearch(int a[],int d);
void main()
{ int a[10],i,d,k,j,t;
clrscr();
for(i=0;i<10;i++)
{ cout<<"\n enter a number::";
cin>>a[i];
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<<"\n enter a number to be searched:";
cin>>d;
int loc=Bsearch(a,d);
if (loc==-1)
cout<<"the number is not found";
Else
cout<<"the position of searched number is:"<<loc;
getch();
int Bsearch(int a[],int d)
int mid,lb=0,ub=9;
while(ub>=lb)
mid=(ub+lb)/2;
if(a[mid]==d)
return mid;
if(a[mid]<d)
lb=mid+1;
else
ub=mid-1;
return -1;
Output:
PRACTICAL NO:- 11
AIM:- Write a program in Visual Basic to find the sum of first 100 numbers
entered using Do loop.
Code:
Private Sub command1_Click()
Dim i, sum As Integer
Sum = 0
i=1
Do
List1.AddItem (i)
sum = sum + i
i=i+1
Loop Until (i > 100)
Text1.Text = sum
End Sub
Output:
Properties:
Sr.no. Control Property Value
type
1 Label Name Label1
Caption TOTAL
2 ListBox Name List1
3 TextBox Name Text1
Text
4 Command Name Command1
Button
Caption CLICK TO ADD
NUMBERS TO LIST
PRACTICAL NO:- 12
AIM:- Create a graphic editor using Visual Basic, which has the following
functions : change color, change border width, change border color etc.
Code:
Private Sub Option1_Click()
Shape1.BackColor = vbRed
End Sub
Private Sub Option2_Click()
Shape1.BackColor = vbGreen
End Sub
Private Sub Option3_Click()
Shape1.BackColor = vbBlue
End Sub
Private Sub Option4_Click()
Shape1.BorderColor = vbRed
End Sub
Private Sub Option5_Click()
Shape1.BorderColor = vbGreen
End Sub
Private Sub Option6_Click()
Shape1.BorderColor = vbBlue
End Sub
Private Sub Option7_Click()
Shape1.BorderWidth = 2
End Sub
Private Sub Option8_Click()
Shape1.BorderWidth = 5
End Sub
Private Sub Option9_Click()
Shape1.BorderWidth = 7
End Sub
OUTPUT:
Properties:
Sr.no. Control types Property Value
1 Shape Name Shape1
BackStyle Opaque
2 Frame Name Frame1
Caption Background
color
3 Option Button Name Option1
4 Option Button Name Option2
5 Option Button Name Option3
6 Frame Name Frame2
Caption Border color
7 Option Button Name Option4
8 Option Button Name Option5
9 Option Button Name Option6
10 Frame Name Frame3
Caption Border Width
11 Option Button Name Option7
12 Option Button Name Option8
13 Option Button Name Option9
PRACTICAL NO:- 13
AIM:- Write a program in Visual Basic that creates a simple form, which asks user
to enter name of the student, marks obtained in subjects1,subject 2 and subject 3.
At the end it should display the complete record.
Code:
Private Sub Command1_Click()
MsgBox (Text1.Text &" "& Text2.Text &" "&Text3.Text &" "& Text4.Text)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Call nextfield(KeyAscii, Text2)
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
Call nextfield(KeyAscii, Text3)
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
Call nextfield(KeyAscii, Text4)
End Sub
Private SubText4_KeyPress(KeyAscii As Integer)
Call nextfield(KeyAscii, Command1)
End Sub
Private Sub nextfield(k As Integer, o As Object)
If k = 13 Then
o.SetFocus
End If
End Sub
Output:
Properties:
Sr.no. Control types Property Value
1 Label Name Label1
Caption ENTER NAME
2 Label Name Label2
Caption SUBJECT1 MARKS
3 Label Name Label3
Caption SUBJECT2 MARKS
4 Label Name Label4
Caption SUBJECT3 MARKS
5 TextBox Name Text1
Text
6 TextBox Name Text2
Text
7 TextBox Name Text3
Text
8 TextBox Name Text4
Text
9 CommandButton Name Command1
Caption SAVE
PRACTICAL NO:- 14
AIM:- Write a program in Visual Basic that constructs a scientific calculator with
SIN, COS, TAN, LOG,1/X (reciprocal) and SQR (Square Root) functions only.
Code:
Dim first, second As Integer
Dim op As String
Private Sub cmd_clear_Click()
Text1.Text = ""
End Sub
Private Sub cmd_add_Click()
first = Text1.Text
op = "+"
Text1.Text = ""
End Sub
Private Sub cmd_sub_Click()
first = Text1.Text
op = "-"
Text1.Text = ""
End Sub
Private Sub cmd_mul_Click()
first = Text1.Text
op = "*"
Text1.Text = ""
End Sub
Private Sub cmd_div_Click()
first = Text1.Text
op = "/"
Text1.Text = ""
End Sub
Private Sub cmd_equal_Click()
second = Text1.Text
If op = "+" Then
Text1.Text = first + second
ElseIf op = "-" Then
Text1.Text = first - second
ElseIf op = "*" Then
Text1.Text = first * second
ElseIf op = "/" Then
Text1.Text = first / second
End If
End Sub
Private Sub cmd_sin_Click()
Dim a
a = CDbl(Text1.Text) * (3.14 / 180)
Text1.Text = Sin(a)
End Sub
Private Sub cmd_cos_Click()
Dim a
a = CDbl(Text1.Text) * (3.14 / 180)
Text1.Text = Cos(a)
End Sub
Private Sub cmd_tan_Click()
Dim a
a = CDbl(Text1.Text) * (3.14 / 180)
Text1.Text = Tan(a)
End Sub
Private Sub cmd_log_Click()
Text1.Text = Log(Text1.Text) / 2.303
End Sub
Private Sub cmd_reci_Click()
Text1.Text = 1 / Text1.Text
End Sub
Private Sub cmd_sqrt_Click()
Text1.Text = Sqr(Text1.Text)
End Sub
Private Sub Command1_Click()
Text1.Text = Text1.Text + "1"
Output:
End Sub
Private Sub Command2_Click()
Text1.Text = Text1.Text + "2"
End Sub
Private Sub Command3_Click()
Text1.Text = Text1.Text + "3"
End Sub
Private Sub Command4_Click()
Text1.Text = Text1.Text + "4"
End Sub
Private Sub Command5_Click()
Text1.Text = Text1.Text + "5"
End Sub
Private Sub Command6_Click()
Text1.Text = Text1.Text + "6"
End Sub
Private Sub Command7_Click()
Text1.Text = Text1.Text + "7"
End Sub
Private Sub Command8_Click()
Text1.Text = Text1.Text + "8"
End Sub
Private Sub Command9_Click()
Text1.Text = Text1.Text + "9"
End Sub
Private Sub Command10_Click()
Text1.Text = Text1.Text + "0"
End Sub
Properties:
Sr.no Control Type Property value
1 TextBox Name Text1
Text
2 Command From 0 to 9 Name Command1to
Command10
3 Command Button Name cmd_sin
Caption Sin
4 Command Button Name cmd_cos
Caption Cos
5 Command Button Name cmd_tan
Caption Tan
6 Command Button Name cmd_add
Caption +
7 Command Button Name cmd_sub
Caption -
8 Command Button Name cmd_mul
Caption *
9 Command Button Name cmd_div
Caption /
10 Command Button Name cmd_clear
Caption clr
11 Command Button Name cmd_equal
Caption =
12 Command Button Name cmd_reci
Caption 1/x
13 Command Button Name cmd_log
Caption Log
14 Command Button Name cmd_sqrt
Caption Sqrt
PRACTICAL NO:- 15
AIM:- Write a program in Visual Basic that calculate area based on selection done
from given to shape: Circle and Rectangle.
Code:
Private Sub Combo1_Click()
If Combo1.Text = "Circle" Then
Label2.Visible = True
Label3.Visible = False
Label4.Visible = False
Text1.Visible = True
Text2.Visible = False
Text3.Visible = False
Shape1.Shape = 3
Shape1.Visible = True
ElseIf Combo1.Text = "Rectangle" Then
Label2.Visible = False
Label3.Visible = True
Label4.Visible = True
Text1.Visible = False
Text2.Visible = True
Text3.Visible = True
Shape1.Shape = 0
Shape1.Visible = True
End If
End Sub
Private Sub Command1_Click()
Dim a As Double
If Combo1.Text = "Circle" Then
a = 3.14 * Text1.Text * Text1.Text
MsgBox ("Area=" & a)
Else
a = Text2.Text * Text3.Text
MsgBox ("Area=" & a)
End If
End Sub
Object & output:
Sr. no. Control Property Value
Type
1 Label Name Label1
Caption SELECT A SHAPE
2 Label Name Label2
Caption ENTER REDIUS
3 Label Name Label3
Caption ENTER LENGTH
4 Label Name Label4
Caption ENTER BRADTH
5 ComboBox Name Combo1
List Circle
Rectangle
6 TextBox Name Text1
Text
7 TextBox Name Text2
Text
8 TextBox Name Text3
Text
9 Command Name Command1
button
Caption Area
10 Shape Name Shape1
Visible False