0% found this document useful (0 votes)
3 views

Assignment 9

Uploaded by

seif798mostafa
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assignment 9

Uploaded by

seif798mostafa
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//Assignment-9-

//-Q1-
//#include <iostream>
//using namespace std;
//template<class T>
//T Max(T number1 , T number2) {
// if (number1 >= number2) {
// return number1;
// }
// else if (number1 <= number2) {
// return number2;
// }
//}
//int main() {
// float x = 10.9, y = 12.7;
// cout << Max(x, y);
//}
//==============================
//-Q2-
//#include <iostream>
//using namespace std;
//template<class T>
//void Swap(T& a, T& b) {
// T tmp = a;
// a = b;
// b = tmp;
//}
//int main() {
// int x = 10, y = 5;
// cout << x << ' ' << y << endl;
// Swap(x, y);
// cout << x << ' ' << y << endl;
//}
//=================================
//-Q3-
//#include <iostream>
//using namespace std;
//template<class T>
//class Calculator {
//public:
// static T add(T x , T y) {
// return x + y;
// }
// static T subtract(T x, T y) {
// return x - y;
// }
// static T multiply(T x, T y) {
// return x * y;
// }
// static T divide(T x, T y) {
// if (y != 0) {
// return x / y;
// }
// else {
// cout << "Cannot divided by zero"<<endl;
// return 0;
// }
// }
//};
//int main() {
// int a = 2, b = 20;
// cout << Calculator<int>::subtract(a,b);
//}
//=================================
//-Q4-
//#include <iostream>
//using namespace std;
//int divide(int x , int y) {
// if (y == 0) {
// throw 0;
// }
// else if (y < 0) {
// throw 1.2;
// }
// return x / y;
//
//}
//int main() {
// int x = 20, y = -1;
// try {
// cout << divide(x, y);
// }
// catch (int) {
// cout << "Cannot divided by zero";
// }
// catch (double) {
// cout<<"Cannot divided by Negative number";
// }
//
//}

You might also like