Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NAME: AYAT ULLAH
- ID: C201050
- SEC: 2BM
- /* Answer 1(a) */
- .... code .....
- #include <iostream>
- using namespace std;
- class Volume{
- double length,breadth,height;
- public:
- Volume(double x=0,double y=0,double z=0):length(x),breadth(y),height(x){}
- };
- int main()
- {
- return 0;
- }
- /* Answer 1(b) */
- .... code .....
- #include <iostream>
- using namespace std;
- class Volume{
- double length,breadth,height;
- public:
- Volume(double x=0,double y=0,double z=0):length(x),breadth(y),height(x){}
- };
- int main()
- {
- return 0;
- }
- /* Answer 1(c) */
- .... code .....
- #include <iostream>
- using namespace std;
- class Rectangle{
- double length,breadth;
- public:
- Rectangle(double x=0,double y=0):length(x),breadth(y){}
- double Area(){
- double area;
- area = length*breadth;
- return area;
- }
- };
- int main()
- {
- Rectangle obj1(4,5),obj2(5,8);
- cout<<obj1.Area()<<endl;
- cout<<obj2.Area();
- return 0;
- }
- /* Answer 1(d) */
- .... code .....
- #include <iostream>
- using namespace std;
- class Student{
- string name ,semester,adress;
- public:
- void getdate(){
- cout<<"Enter name: ";
- cin>>name;
- cout<<"Enter Semester :";
- cin>>semester;
- cout<<"Enter adress :";
- cin.ignore();
- cin>>adress;
- }
- void showdate(){
- cout<<name<<"\t\t\t"<<semester<<"\t\t\t"<<adress<<endl;
- }
- };
- int main()
- {
- Student obj[3];
- for(int i=0;i<3;i++){
- system("cls");
- cout<<"Student"<<i+1<<endl;
- obj[i].getdate();
- }
- cout<<"Name\t\t\tSemester\t\t\tAdress\n";
- for(int i=0;i<3;i++){
- obj[i].showdate();
- }
- return 0;
- }
- /* Answer 2(a) */
- .... code .....
- #include <iostream>
- using namespace std;
- class Student{
- double height;
- public:
- static double theight;
- void getdate(){
- cout<<"Enter student height :";
- cin>>height;
- theight+=height;
- }
- };
- double Student::theight=0;
- int main()
- {
- int n;
- cout<<"Enter total student number :";
- cin>>n;
- Student obj[n];
- for(int i=0;i<n;i++){
- system("cls");
- cout<<"Student "<<i+1<<endl;
- obj[i].getdate();
- }
- cout<<"Median of height is "<<Student::theight/n<<endl;
- return 0;
- }
- /* Answer 2(b) */
- .... code .....
- #include <iostream>
- using namespace std;
- class Dict{
- string name="NOT SET",adress="NOT SET",mn="NOT SET",gender="NOT SET",nid="NOT SET";
- public:
- Dict(string x,string y,string z,string i,string j):name(x),adress(y),mn(z),gender(i),nid(j){}
- Dict(string x,string y,string i,string j):name(x),adress(y),gender(i),nid(j){}
- void pdata(){
- cout<<name<<" "<<adress<<" ";
- if(mn!="NOT SET"){
- cout<<mn<<" ";
- }
- cout<<gender<<" "<<nid<<endl;
- }
- };
- int main()
- {
- Dict obj1("ayat ullah","kumira,shitakunda","01926668875","male","3687554"),obj2("ayat ullah","kumira,shitakunda","male","3687554");
- obj1.pdata();
- obj2.pdata();
- return 0;
- }
- /* Answer 2(c) */
- .... code .....
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- string fname,mname,lname;
- cin>>fname>>mname>>lname;
- cout<<fname<<" "<<mname[0]<<"."<<lname[0]<<"."<<endl;
- return 0;
- }
- /* Answer 3(a) */
- .... code .....
- #include<bits/stdc++.h>
- using namespace std;
- class AddAmount{
- float ammount=0,tammount=50;
- public:
- AddAmount (float x=50):ammount(x){tammount+=ammount;}
- AddAmount(){
- tammount+=0;
- }
- void getdata(){
- cout<<tammount<<endl;
- }
- };
- int main(){
- AddAmount obj1(),obj2(500);
- //obj1.getdata();
- obj2.getdata();
- return 0;
- }
- /* Answer 3(b) */
- .... code .....
- #include<bits/stdc++.h>
- using namespace std;
- class PrintNumber{
- int num;
- public:
- int printn(int x){
- cout<<x;
- }
- long long printn(long long x){
- cout<<x;
- }
- float printn(float x){
- cout<<x;
- }
- double printn(double x){
- cout<<x;
- }
- };
- int main(){
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment