Lab Task
Lab Task
Lab Task
#include <iostream>
class student {
public:
string name;
int roll_no;
};
int main() {
student st1;
st1.name = "john";
st1.roll_no = 2;
return 0;
Problem 2
#include <iostream>
class Student{
public:
string roll_no,phonenumber;
string name,address;
void printDetails(){
cout<<"Name: "<<name<<endl;
cout<<"Address: "<<address<<endl;
};
int main(){
Student student1,student2;
student1.name = "Sam";
student1.address = "kuril";
student1.roll_no = "19";
student1.phonenumber = "0123456789";
student1.printDetails();
cout<<endl;
student2.name = "John";
student2.address = "Nikunjo";
student2.roll_no = "11";
student2.phonenumber = "0123456789";
student2.printDetails();
return 0;
}
Problem 3
#include <iostream>
#include<cmath>
class Triangle {
public:
double area(){
return area;
double perimeter() {
void display(){
};
int main() {
Triangle triangle;
triangle.side1 = 3;
triangle.side2 = 4;
triangle.side3 = 5;
triangle.display();
return 0;
Problem 4
#include <iostream>
class Triangle
public:
s1 = a;
s2 = b;
s3 = c;
void print_area()
double s = (s1+s2+s3)/2;
};
int main()
Triangle t(3,4,5);
t.print_area();
return 0;
}
Problem 5
#include <iostream>
class Rectangle {
public:
int length;
int breadth;
Rectangle(int l, int b) {
length = l;
breadth = b;
int Area() {
};
int main() {
return 0;
Problem 6
#include <iostream>
class Area{
public:
int length;
int breadth;
length = l;
breadth = b;
int getArea(){
return length*breadth;
};
int main(){
Area a;
a.setDim(4,5);
return 0;
Problem 7
#include <iostream>
class Area {
public:
int length;
int breadth;
Area(int l, int b) {
length = l;
breadth = b;
int returnArea() {
};
int main() {
int l, b;
cin >> l;
cin >> b;
return 0;
Problem 8
#include <iostream>
class Average {
public:
void calculateAverage(int num1, int num2, int num3){
cout << "The average of the three numbers is: " << average << std::endl;
};
int main()
return 0;
}
Problem 9
#include <iostream>
class Complex {
public:
float real;
float imag;
Complex(float r = 0, float i = 0) {
real = r;
imag = i;
Complex res;
return res;
Complex res;
return res;
Complex res;
return res;
}
};
int main() {
cout << "Enter real and imaginary parts of first complex number: ";
cout << "Enter real and imaginary parts of second complex number: ";
cout << "Sum = " << sum.real << " + " << sum.imag << "i" << endl;
cout << "Difference = " << diff.real << " + " << diff.imag << "i" << endl;
cout << "Product = " << prod.real << " + " << prod.imag << "i" << endl;
return 0;
Problem 10
#include <iostream>
private:
int length;
int width;
int height;
public:
length=l;
width=w;
height= h;
int getvol(){
return length*width*height;
};
int main(){
Volume rect;
cin>>length;
cin>>width;
cin>>height;
return 0;