Registration Number: 1912267
Registration Number: 1912267
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()
{
}
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()
{
int main()
{
Student S1;
S1.set_Student();
S1.show_Student();
}
Output:
Question 2:
#include<iostream>
using namespace std;
class Triangle
{
public:
#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++);
}
};
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: