0% found this document useful (0 votes)
10 views17 pages

Practical File

The document contains a series of programming tasks and their corresponding code implementations in HTML, Visual Basic, and C++. It includes creating a college profile webpage, generating lists and tables, performing arithmetic operations, and implementing class hierarchies. Additionally, it covers concepts like operator overloading, sorting algorithms, and virtual functions.

Uploaded by

pinaloswal1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views17 pages

Practical File

The document contains a series of programming tasks and their corresponding code implementations in HTML, Visual Basic, and C++. It includes creating a college profile webpage, generating lists and tables, performing arithmetic operations, and implementing class hierarchies. Additionally, it covers concepts like operator overloading, sorting algorithms, and virtual functions.

Uploaded by

pinaloswal1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

1)Create a simple HTML page on College profile.

The page must consist of at least


3 paragraphs of text. The page must have an appropriate title, background color or
background image. The paragraphs must have text consisting of different colors
and styles in terms of alignments and Font styles.

Program Code:-
<Html>
<Head>
<Title>College profile</Title></Head>
<Body background="img5.jpg" Text="Yellow">
<Center>
<h1>Tuljaram Chaturchand College Baramati</h1><br>
<h2>College Profile</h2>
<Hr color="green">
<Marquee>
<Img Height="100px" width="100px" src="img2.jpg">
</Marquee><br>
<p align="right"><font face="Arial" size="12" color="orange"> T.C. college
conducted junior XI,XII Arts,science,Commerce & MCVC Science having
additional subjects like IT,Computer Science,Electronics.</font></p>
<p align="center"><font face="Times New Roman" size="14" color="green">
College having senior courses like B.SC,BBA,BCA,BCS All these courses are 3
years.</font></p>
<p align="left"><font face="Ink free" size="10" color="blue"> Post graduation
courses are M.SC,MCA,MBA,MCS having duration 2 years </font></p>
</Center>
</Body>
</Html>
Program Output:-
2)Write a HTML program to generate the following output.

 Arts
1.Marathi

2.Hindi

 Commerce
i .Account

ii.Costing

 Science
A.Physics

B.Chemistry

Program code:-

<html>
<head><title>list</title></head>
<body>
<ul type="disc">
<li>Arts</li>
<ol type="1">
<li>Marathi</li>
<li>Hindi</li>
</ol>
<li>Commerce</li>
<ol type="i">
<li>Account</li>
<li>Costing</li>
</ol>
<li>Science</li>
<ol type="A">
<li>Physics</li>
<li>Chemistry</li>
</ol>
</ul>
</body>
</html>
Output-

3) Write a HTML program to generate the following table Structure.

Students
Year
Boys Girls Total

2016 50 75 125

2017 75 95 170

Program Code:-
<html>
<head><title>table tag</title></head>
<body>
<table border="2" bgcolor="orange" align="center" cellpadding="10">
<tr>
<th rowspan="2">Year</th>
<th colspan="3">Students</th>
</tr>
<tr>
<td>Boys</td>
<td>Girls</td>
<td>Total</td>
</tr>
<tr>
<td>2016</td>
<td>50</td>
<td>75</td>
<td>125</td>
</tr>
<tr>
<td>2017</td>
<td>75</td>
<td>95</td>
<td>170</td>
</tr>
</body>
</html>

Output-

4)Write a program in Visual Basic that performs Arithmetic Operations.


Program code:-
Private Sub Command1_Click()
Command1.Caption = Val(Text1.Text) + (Text2.Text)
End Sub
Private Sub Command2_Click()
Command2.Caption = Val(Text1.Text) - (Text2.Text)
End Sub
Private Sub Command3_Click()
Command3.Caption = Val(Text1.Text) * (Text2.Text)
End Sub
Private Sub Command4_Click()
Command4.Caption = Val(Text1.Text) / (Text2.Text)
End Sub
Private Sub Command5_Click()
Command5.Caption = (Val(Text1.Text) + Val(Text2.Text)) / 2
End Sub

Output:-
5)Write a visual basic program to calculate sum of n numbers using while loop.

Program code:-
Dim i, n, sum As Integer
Private Sub Command1_Click()
n = Val(Text1.Text)
sum = 0
i=1
While (i <= n)
sum = sum + i
i=i+1
Wend
Command1.Caption = sum
End Sub

Output:-
6)Design an application with 2 list box. Transfer all these list items from list 1 to
list 2 when click on transfer button as well as remove item when click remove
button.

Program code:-
Dim i As Integer
Private Sub Command1_Click()
For i = 0 To List1.ListCount
List2.List(i) = List1.List(i)
Next i
End Sub
Private Sub Command2_Click()
For i = 0 To List1.ListCount
List2.RemoveItem (i)
Exit For
Next i
End Sub
Output:-

7)Create graphic editor in visual basic which has following change color n width of
shape.
Program 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.BorderWidth = 2
End Sub
Private Sub Option5_Click()
Shape1.BorderWidth = 5
End Sub
Private Sub Option6_Click()
Shape1.BorderWidth = 7
End Sub
Output:-

8)Write a program in Visual Basic that calculates area and selection of two shapes,
circle and rectangle.

Program Code:-
Dim a As Double
Program Code:-
Private Sub Combo1_change()
If Combo1.Text = "circle" Then
Label2.Visible = True
Text1.Visible = True
Label3.Visible = False
End Sub
Text2.Visible = False
Label4.Visible = False
Text3.Visible = False
ElseIf combotext = "rectangle" Then
Label2.Visible = False
Text1.Visible = False
Label3.Visible = True
Text2.Visible = True
Label4.Visible = True
Text3.Visible = True
End If
End Sub
Private Sub Command1_Click()
If Combo1.Text = "circle" Then
a = 3.14 * Val(Text1.Text) * Val(Text1.Text)
MsgBox ("area" & a)
Else
a = Val(Text2.Text) * Val(Text3.Text)
MsgBox ("area" & a)
End If
End Sub
Output:-

9) Write a program in C++ to print the Fibonacci series.

Program Code:-
#include<iostream.h>
#include<conio.h>
void main( )
{
int f0=0,f1=1,f,n,i;
clrscr( );
cout<<"enter any number";
cin>>n;
cout<<"Fibonacci’s series is";
cout<<f0<<endl;
cout<<f1<<endl;
for(i=1;i<=n;i++)
{
f=f0+f1;
cout<<f<<endl;
f0=f1;
f1=f;
}
getch( );
}

Output-
enter any number 10
Fibonacci’s series is
0
1
1
2
3
5
8
13
21
34
55
89

10) Write a program in C++ , to implement the following class Hierarchy : Class
Student to obtain Roll number , Class Test to obtain marks scored in two different
subjects , Class Sport to obtain weightage (marks in sports) and Class result to
calculate the total marks. The program must print the roll number, individual
marks obtained in two subjects, sports and total marks.

student

test sports

result
Program Code:-

#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:"<<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:\n s1="<<s1<<"\n s2="<<s2;
}
};
class sports
{
public:
int score;
void get_score(int x)
{
score=x;
}
void put_score(void)
{
cout<<"\n sports marks:"<<score;
}
};
class result:public test,public sports
{
float tot;
public:
void display(void)
{
tot=s1+s2+score;
put_no( );
put_marks( );
put_score( );
cout<<"\n 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:101
marks obtained:
s1=39
s2=65
sports marks:29
total score= 133

11)Write a program in C++ to overload unary operator and reverse the given
string.
Program Code:-
#include<iostream.h>
#include<conio.h>
#include<string.h>
class data
{
private:
char str[20];
public:
void get( );
void put( );
void operator !( );
};
void data::get( )
{
cout<<"\n enter the string="; cin>>str;
}
void data::put( )
{
cout<<"\n string="<<str;
}
void data::operator!( )
{
strrev(str);
}
void main( )
{
clrscr( );
data d;
d.get( );
d.put( );
!d;
d.put( );
getch( );
}
Output-
enter the string= komal
string =komal
string=lamok
******************************************************************
12) Write a program in C++ that initializes a 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 is called. The program must display “Object Dies” when the class
destructor is called for the object when it reached the end of its scope.
Program Code:-
#include<iostream.h>
#include<conio.h>
class data
{
private:
int a;
public:
data( );
~data( );
void put( );
};
data::data( )
{
a=10;
cout<<"\n object is born";
}
void data::put( )
{
cout<<"\n object is alive";
cout<<"\n a="<<a;
}
data::~data( )
{
cout<<"\n object is die";
}
void main( )
{
clrscr( );
data d;
d.put( );
getch( );
}

Output-
object is born
object is alive
a=10
13) Write a program in C++ to demonstrate virtual function.
Program Code:-
#include<iostream.h>

#include<conio.h>

class base

public:

virtual void show( )

cout<<"base class";

};
class der1: public base

void show( )

cout<<"derived class 1"<<endl;

};

class der2: public base

public:

void show( )

cout<<"derived class 2"<<endl;

};

void main( )

clrscr( );

der1 d1;

der2 d2;

base* ptr;

ptr=&d1;

ptr->show( );

ptr=&d2;

ptr->show( );

getch( );
}

Output-

derived class1

derived class2

14)Write a program in C++ that first initializes an array of given 10 integer


numbers.
The program must sort numbers in descending order-using Bubble – sort

Program Code:-
#include<iostream.h>
#include<conio.h>
class sort
{
private:
int a[10];
int n,i,j,temp;
public:
void accept( )
{
cout<<“******************input****************”<<endl;
cout<<“How many numbers”<<endl;
cin>>n;
cout<<“Enter the element:”;
for(i=1;i<=n;i++)
{
cin>>a[i];
}
}
void process( )
{
for(i=1;i<=(n-1);i++)
{
for(j=1;j<=n-1;j++)
{
if(a[j]<a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
void display( )
{
cout<<“***********output*******”<<endl;
cout<<“Descending order is:\n”;
for(i=1;i<=n;i++)
{
cout<<a[i]<< “\t”;
}
}
};
void main( )
{
clrscr( );
sort s;
s.accept( );
s.process( );
s.display( );
getch( );
}

Output-
**********input***********
How many numbers :
5
Enter the element: 23 45 67 89 48
***********output***********
Descending order is:
89 67 48 45 23

You might also like