Saturday 16 May 2015

OOP Lecture 16th May 2015

Program 1 :

#include <iostream>

using namespace std;



int max(int, int); // Function Decleration

int main()
{
int num1, num2, answer;
int c;

do
{

cout << "Enter the First number :";

cin >> num1;



cout << "Enter the second number :";
cin >> num2;

answer = max(num1, num2); // Function Call

cout << "The Answer is =" << answer << endl;
cout << "Do You want to Continue ? (1/0) :";

cin >> c;


} while (c == 1);

return 0;


}


int max(int num1, int num2) // Function Defination
{
int result;
if (num1 > num2)

result = num1;

else
result = num2;

return result;

}


Program 2:

#include<iostream>

using namespace std;

struct height
{
int feet, inches;
};

int main()

{
height ff_1;
height fi_1;
height ff_2;
height fi_2;
height ft;
height it;

cout << "Enter the Measurments of Floor 1 in ft :" << endl;
cin >> ff_1.feet;

cout << "Enter the Measurments of Floor 1 in inches :" << endl;
cin >> fi_1.inches;

cout << "Enter the Measurments of Floor 2 in ft :" << endl;
cin >> ff_2.feet;

cout << "Enter the Measurments of Floor 2 in inches :" << endl;
cin >> fi_2.inches;


ft.feet = ff_1.feet + ff_2.feet;

it.inches = fi_1.inches + fi_2.inches;

if (it.inches >= 12)
{


ft.feet++;
it.inches -= 12;

}

cout << "Height of Both floors is  :" << ft.feet << "`" << "-" << it.inches << "``" <<endl;



getchar();

return 0;







}