You are on page 1of 9

Registration number: 1912267

Question 1:
#include<iostream>
using namespace std;

class Address{
private:
char street[10], House[10], Country[10], City[10];
public:

void disp_Address()
{

cout << "your country = " << Country << endl;

cout << "your City = " << City << endl;

cout << "your street no = " << street << endl;


cout << "your house no = "<< House << endl;

}
void set_Address()
{
cout << "enter Country = ";
cin >> Country;
cout << "enter City = ";
cin >> City;
cout<<"enter your house no = ";
cin>>House;
cout << "enter your Street no = ";
cin >> street;

}
};

class Student{
private:
int Reg_no;

string name;

Address address;
public:
void set_Student()
{
cout << "Enter Reg no of student = ";
cin >> Reg_no;
address.set_Address();
}
void show_Student()
{

cout << "Name = " << name << endl;


cout << "Reg no = " << Reg_no << endl;
address.disp_Address();
}
};

int main()
{
Student S1;
S1.set_Student();

S1.show_Student();
}

Output:
Question 2:
#include<iostream>
using namespace std;
class Triangle
{
public:

void Verify_Triangle(int a1, int a2, int a3)


{
int sum;
sum = a1 + a2 + a3;
if (sum > 180)
{
cout << "Triangle is Valid ! " << endl;
}
else
{
cout << "Triangle is Invalid ! " << endl;
}
}
};
int main()
{
Triangle t;
int ang1, ang2, ang3;
cout << "Enter angle 1 : ";
cin >> ang1;
cout << "Enter angle 2 : ";
cin >> ang2;
cout << "Enter angle 3 : ";
cin >> ang3;
cout << endl;
t.Verify_Triangle(ang1, ang2, ang3);
system("pause");
return 0;
}
Output:
Question:3

#include<iostream>
using namespace std;

class counter{
private:
int num;
public:
counter(int n=0)
{
num=n;
}
// prefix
counter operator --()
{
return counter(--num);
}
counter operator ++()
{
return counter(++num);
}
//postfix
counter operator ++(int)
{
return counter(num++);
}

counter operator --(int)


{
return counter(num--);
}

};
int main()
{
counter c1,c2;
cout<<"\nPostfix\n";
cout<<"*********Increment *******"<<endl;
for(int c1=0; c1<=10; c1++)
{
cout<<c1<<" ";;
}
cout<<"\n\n*********Decrement*******"<<endl;
for(int c2=10; c2>=0; c2--)
{
cout<<c2<<" ";
}
cout<<"\n\nPrefix\n";
cout<<"*********Increment *******"<<endl;
for(int c1=0; c1<=10; ++c1)
{
cout<<c1<<" ";;
}
cout<<"\n\n*********Decrement*******"<<endl;
for(int c2=10; c2>=0; --c2)
{
cout<<c2<<" ";
}

return 0;
}
Output:

You might also like