SSRWD Practical
SSRWD Practical
INDEX
Serial Faculty
Practical name Page no. Date
No. signature
1
Program – 1
Output:-
2
Program-2
Output:-
3
Program – 3
Output:-
4
Program – 4
Output:-
5
Program – 5
Output:-
6
Program – 6
</select>
</body>
</html>
Output:-
7
Program – 7
Output:-
9
Program – 8
</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
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);
Program – 11
Output:-
14
Program – 12
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
class Shape {
public:
virtual void draw() = 0;
};
void main() {
clrscr();
Circle circle;
Rectangle rectangle;
circle.draw();
rectangle.draw();
getch();
}
Output:-
17
Program – 14
Output:-
18
Program – 15
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:-