[go: up one dir, main page]

0% found this document useful (0 votes)
5 views21 pages

SSRWD Practical

The document contains a series of HTML and C++ programming examples, each demonstrating different concepts such as HTML tags, text formatting, tables, dropdown menus, and various programming paradigms in C++. Each program is labeled with a topic and includes code snippets that illustrate the respective concepts. The document serves as a practical guide for learning HTML and C++ programming.

Uploaded by

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

SSRWD Practical

The document contains a series of HTML and C++ programming examples, each demonstrating different concepts such as HTML tags, text formatting, tables, dropdown menus, and various programming paradigms in C++. Each program is labeled with a topic and includes code snippets that illustrate the respective concepts. The document serves as a practical guide for learning HTML and C++ programming.

Uploaded by

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

0

INDEX

Serial Faculty
Practical name Page no. Date
No. signature
1

Program – 1

Topic: Heading tags.


<html>
<head>
<title>This is my first class</title>
</head>
<body>
<h1>This is my first class</h1>
<h2>This is my first class</h2>
<h3>This is my first class</h3>
<h4>This is my first class</h4>
<h5>This is my first class</h5>
<h6>This is my first class</h6>
</body>
</html>

Output:-
2

Program-2

Topic: Bold, Underline, Italics, Subscript, Superscript.


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Formatting Text</title>
</head>
<body>
<h2><b>Bold="B"</b></h2>
<h2><u>Underline="U"</u></h2>
<H2?><i>Italic="I"</i></H2>
<h2>H<sub>2</sub>O</h2>
<H2>X<sup>2</sup></H2>
</body>
</html>

Output:-
3

Program – 3

Topic: Student detail table.


<html>
<head>
<title>Document</title>
</head>
<style>table,th,td{border:1px solid black}</style>
<body>
<h2> A basic html table(Student list)</h2>
<table style="width:75%">
<tr>
<th>Student Name</th>
<th>Contact</th>
<th>City</th>
</tr>
<tr>
<td>Shohrat Singh</td>
<td>456789067</td>
<td>Gurugram</td>
</tr>
<tr>
<td>Himanshu</td>
<td>453456787</td>
<td>Delhi</td>
</tr>
<tr>
<td>Shahbaz</td>
<td>87654367</td>
<td>Delhi</td>
</tr>
</table>
</body>
</html>

Output:-
4

Program – 4

Topic: Bi-Directional Override tag.


<html>
<head>
<title>Document</title>
</head>
<body>
<h3><p>This text will go Right-to-Left</p></h3>
<bdo dir="rtl">Computer Science & Engineering</bdo>
<h3><p>This text will go Lrft-to-Right</p></h3>
<bdo dir="ltr">Computer Science & Engineering</bdo>
</body>
</html>

Output:-
5

Program – 5

Topic: Keyboard input tag.


<html>
<head>
<title>Document</title>
</head>
<body>
<p>
Press <kbd>Ctrl</kbd> + <kbd>P</kbd> To Print Command
</p>
</body>
</html>

Output:-
6

Program – 6

Topic: Dropdown menu.


<html>
<head>
<title>My Dropdown Menu</title>
</head>
<body>
<label for="dropdown">Choose Qualifications</label>
<select id="dropdown" name="dropdown">
<option value="option1">BBA</option>
<option value="option2">BCA</option>
<option value="option3">MBA</option>
<option value="option4">M.Tech(CSE)</option>
<option value="option5">M.Tech(ME)</option>
<option value="option6">B.Tech(CSE)</option>
<option value="option7">B.Tech(AI & DS)</option>
<option value="option8">B.Tech(ECE)</option>
<option value="option9">B.Tech(EEE)</option>

</select>
</body>
</html>

Output:-
7

Program – 7

Topic: Fonts and colors.


<html>
<head>
<title>These are the colors of Rainbow</title>
</head>
<body>
<h3>These are the seven colors of Rainbow:</h3>
<p>
<font face="Arial" color="red">
This is RED color.
</font>
</p>
<p>
<font face="Calibri" color="orange">
This is ORANGE color.
</font>
</p>
<p>
<font face="Century" color="yellow">
This is YELLOW color.
</font>
</p>
<p>
<font face="Chiller" color="green">
This is GREEN color.
</font>
</p>
<p>
<font face="Cooper Black" color="blue">
This is BLUE color.
</font>
</p>
<p>
<font face="Elephant" color="indigo">
This is INDIGO color.
</font>
</p>
<p>
<font face="Forte" color="violet">
This is VIOLET color.
</font>
</p>
</body>
</html>
8

Output:-
9

Program – 8

Topic: Time Table.


<html>
<head>
<title>Time Table</title>
</head>
<body bgcolor="white">
<h1><font color="red"><center>B.M. GROUPS OF INSTITUTIONS</center></font></h1>
<table border="2" cellspacing="3" align="center">
<h2><font color="blue"><center>BCA 4th Sem Class Time Table</center></font></h2>
<table border="2" cellspacing="3" align="center">
<tr>
<td align="center">
<td>09:20 - 10:05
<td>10:05 - 10:50
<td>10:50 - 11:35
<td>11:35 - 12:20
<td>12:20 - 01:05
<td>01:05 - 01:50
<td>01:50 - 02:35
<td>02:35 - 03:20
</tr>
<tr>
<td align="center">MONDAY
<td align="center"><font color="green">OOPC(L)</font><td align="center">
<font color="blue">DSII<br>
<td align="center"><font color="maroon">SE<br>
<td align="center"><font color="red">WD(L)<br>
<td rowspan="6" align="center">L<br>U<br>N<br>C<br>H
<td colspan = "2" align="center"><font color="pink">OOPC(LAB)<br>
<td align="center"><font color="red">WD(L)
</tr>
<tr>
<td align="center">TUESDAY
<td align="center"><font color="blue">DSII<br>
<td align="center"><font color="black">LIB<br>
<td colspan = "2" align="center"><font color="orange">WD(LAB)<br>
<td align="center"><font color="red">WD(L)
<td align="center"><font color="black">LIB<br>
<td align="center"><font color="maroon">SE
</tr>
<tr>
<td align ="center">WEDNESDAY
<td align="center"><font color="green">OOPC(L)<br>
<td align="center"><font color="maroon">SE<br>
<td colspan = "2" align="center"><font color="orange">WD(LAB)<br>
<td colspan = "2" align="center"><font color="pink">OOPC(LAB)
<td align="center"><font color="maroon">SE
10

</tr>
<tr>
<td align="center">THURSDAY
<td align="center"><font color="green">OOPC(L)<br>
<td colspan = "2" align="center"><font color="orange">WD(LAB)<br>
<td align="center"><font color="blue">DSII<br>
<td align="center"><font color="red">WD(L)<br>
<td align="center"><font color="blue">DSII<br>
<td align="center"><font color="maroon">SE
</tr>
<tr>
<td align="center">FRIDAY
<td align="center"><font color="green">OOPC(L)<br>
<td align="center"><font color="blue">DSII<br>
<td align="center"><font color="maroon">SE<br>
<td align="center"><font color="pink">OOPC(LAB)
<td align="center"><font color="black">LIB<br>
<td align="center"><font color="blue">DSII<br>
<td align="center"><font color="purple">SPORTS
</tr>
</body>
</html>

Output:-
11

Program – 9

Topic:- Write a program in which a function is defined inside class.


#include<conio.h>
#include<iostream.h>
class item{
int number;
float cost;
public:
void getdata(int a, float b);
void putdata(void){
cout<< "number: " << number << "\n";
cout<< "cost: " <<cost <<"\n";
}
};
void item :: getdata (int a, float b)
{
number = a;
cost = b;
}
void main()
{
clrscr();
item x;
cout << "\nobject x" <<"\n";
x.getdata(100, 299.95);
x.putdata();
item y;
y.getdata(200, 175.50);
y.putdata();
getch();
}

Output:-
12

Program – 10

Topic:- Write a program in which a data member of a class can be qualified as Static
Class Member.
#include<iostream.h>
#include<conio.h>
class item
{
static int count;
int number;
public:
void getdata(int a)
{
number = a;
count ++;
}
void getcount(void)
{
cout<< "Count: ";
cout<< count << "\n";
}
};
int item :: count;
void main()
{
clrscr();
item a, b, c;
a.getcount();
b.getcount();
c.getcount();
a.getdata(100);
b.getdata(200);
c.getdata(300);

cout << "After reading data"<<"\n";


a.getcount();
b.getcount();
c.getcount();
getch();
}
Output:-
13

Program – 11

Topic:- Write a program which shows the use of a Friend Function.


#include<iostream.h>
#include<conio.h>
class sample
{
int a;
int b;
public:
void setvalue()
{
a=25;
b=40;
}
friend float mean(sample s);
};
float mean(sample s)
{
return float (s.a + s.b)/2.0;
}
void main()
{ clrscr();
sample X;
X.setvalue();
cout<< "Mean value =" << mean(X) << "\n";
getch();
}

Output:-
14

Program – 12

Topic:- Write a program to illustrate a simple example of Inheritance.


#include<iostream.h>
#include<conio.h>

class B
{
int a;
public:
int b;
void set_ab();
int get_a(void);
void show_a(void);
};

class D : public B
{
int c;
public:
void mul(void);
void display(void);
};

void B :: set_ab(void)
{
a = 5;
b = 10;
}
int B :: get_a()
{
return a;
}

void B :: show_a()
{
cout << "a = " << a <<"\n";
}

void D :: mul()
{
c = b*get_a();
}
void D :: display()
{
cout << "a = " << get_a() << "\n";
cout << "b = " << b << "\n";
cout << "c = " << c << "\n\n";
}
15

void main()
{
clrscr();
D d;
d.set_ab();
d.mul();
d.show_a();
d.display();
d.b = 20;
d.mul();
d.display();
getch();
}

Output:-
16

Program – 13

Topic:- Write a program to illustrate a simple program of Abstract class.


#include <iostream.h>
#include<conio.h>

class Shape {
public:
virtual void draw() = 0;
};

class Circle : public Shape {


public:
void draw() {
cout << "This function is for a circle...";
}
};
class Rectangle : public Shape {
public:
void draw() {
cout << "\nThis function is for a rectangle...";
}
};

void main() {
clrscr();
Circle circle;
Rectangle rectangle;
circle.draw();
rectangle.draw();

getch();
}

Output:-
17

Program – 14

Topic:- Write a simple program to illustrate Virtual function.


#include <iostream.h>
#include<conio.h>
class Shape {
public:
virtual float area() const = 0;
};
class Rectangle : public Shape {
private:
float length;
float width;
public:
Rectangle(float l, float w) : length(l), width(w) {}
float area() const {
return length * width;
}
};
class Circle : public Shape {
private:
float radius;
public:
Circle(float r) : radius(r) {}
float area() const {
return 3.14 * radius * radius;
}
};
void main() {
clrscr();
Shape* shape1 = new Rectangle(5, 4);
Shape* shape2 = new Circle(3);
cout << "Area of Rectangle: " << shape1->area() << endl;
cout << "Area of Circle: " << shape2->area() << endl;
delete shape1;
delete shape2;
getch();
}

Output:-
18

Program – 15

Topic:- Write a program to illustrate Constructor & Destructor.


#include <iostream.h>
#include<conio.h>

class MyClass {
private:
static int count;
int id;

public:
MyClass()
{
count++;
id = count;
cout << "\nConstructor called for object with ID: " << id;
}

~MyClass()
{
cout << "\nDestructor called for object with ID: " << id;
}
void displayInfo()
{
cout << "\nObject ID: " << id;
}
static int getCount()
{
return count;
}
};

int MyClass::count = 0;

void main() {
clrscr();
cout << "\nCreating objects...";
const int numObjects = 5;
MyClass objects[numObjects];
cout << "\nDisplaying information of all objects...";
for (int i = 0; i < numObjects; ++i)
{
objects[i].displayInfo();
}
cout << "\nTotal number of objects created: " << MyClass::getCount();
cout << "\nEnd of main function...";
getch();
}
19

Output:-
20

Program – 16

Topic:- Use of vector class template for performing scalar product of int type
vectors and float type vectors.
#include <iostream.h>
#include<conio.h>
const size=3;
template <class T>
class vector
{
T* v;
public:
vector()
{
v= new T[size];
for(int i=0;i<size;i++)
v[i]=0;
}
vector(T* a)
{
for(int i=0;i<size;i++)
v[i]=a[i];
}
T operator*(vector &y)
{
T sum=0;
for(int i=0;i<size;i++)
sum += this-> v[i] * y.v[i];
return sum;
}
};
void main() {
clrscr();
int x[3]={1,2,3};
int y[3]={4,5,6};
vector <int> v1;
vector <int> v2;
v1=x;
v2=y;
int R=v1 * v2;
cout<<"\nR= "<<R<<"\n";
getch();
}

Output:-

You might also like