Lab Report 7 Muhammad ABdullah Zafar Ghauri ME - 14 405642
Lab Report 7 Muhammad ABdullah Zafar Ghauri ME - 14 405642
Lab Report 07
1st SEMESTER
Theory:
#include<iostream>
using namespace std;
int main()
{
cout << "\n My Name is Abdullah Zafar";
cout << "\n I Study in ME-14 (C) ";
cout << "\n My CMS ID is 405642";
return 0;
}
Output:
Q.1 Write a program in C++ comprising of class, user-defined functions with also
including default and parameterized functions.
• Program as Input:
#include<iostream>
using namespace std;
class area
{
private:
double base, height;
public:
area(); //Default Constructor
area(double _base, double _height); //Parameterized Function
double calculateArea()
{
return base*height;
}
};
Here header file has been declared as Area.h. It is to be called later in .cpp file.
#include<iostream>
#include<cmath>
#include"area.h"
using namespace std;
area::area()
{
cout << "\nInitializing the default values,i.e. 0,0";
base = 0.0;
height = 0.0;
}
area::area(double _base, double _height)
{
cout << "\nInitalizing with the values";
base = _base;
height = _height;
}
int main()
{
double result = 0;
area obj;
area obj2(10.0, 20.0);
result= obj2.calculateArea();
cout << "\nThe Result as after calcualtion of area is=" << result;
return 0;
}
Output:
LAB TASKS:
Program:
#include<iostream>
using namespace std;
class arshad_shareef
{
private:
int a, b;
public:
int arshad()
{
cout << "I pay my respect to him and condolences";
cout << "\n to him family";
return 0;
}
arshad_shareef()
{
cout << "I am declared";
arshad();
}
arshad_shareef(int xy, int yz)
{
cout << "I am declared parameterized";
cout << "\n with values" << xy << " " << yz;
}
};
int main()
{
arshad_shareef obj;
obj.arshad();
}
Output:
Program as Input:
#include<iostream>
#include<cmath>
using namespace std;
int country();
float product(float a, float b);
char toupper(char a);
int main()
{
cout << toupper('s');
}
char toupper(char a)
{
return a - 32;
}
float product(float a, float b)
{
return a * b;
}
int country()
{
cout << "\n They lost in a fit of lust of power and proudness and
overconfidence!!!";
return 0;
}
Output:
Input:
#include<iostream>
#include<cmath>
using namespace std;
class programming
{
private:
int a;
int b;
public:
programming(); //Default Constructor
//programming(int x, int y); //Parameterized Constructor
bool user(int x, int y)
{
return x >= y;
}
int point(int x, int y)
{
a = x;
b = y;
}
int point2(int x, int y)
{
return sqrt(pow(x - a, 2) + pow(x - b, 2));
}
};
int main()
{
Output:
#include<iostream>
#include "programming.h" //Calling the member class from .h file
using namespace std;
programming::programming(int x, int y)
{
cout << "Bonjour! Hello Wie geht's?";
a = x;
b = y;
}
int main()
{
#include<iostream>
using namespace std;
class pakistan
{
private:
int a, b;
public:
int quaid()
{
cout << "History taeches man great everlasting deep lessons that should
never be forgotten!" << endl;
a = 0;
b = 0;
cout << endl << a << " " << b;
return 0;
}
pakistan() //default constructor
{
cout << "Bonjour Wie Gehts? Es Geht's Danke! Es Geht wie allen?";
a = 0;
b = 0;
}
pakistan(int x, int y)
{
cout << "Es Geht Wie Allen?" << x * y << " times";
char toupper(char a)
{
return a - 32;
}
Output: