// Simple example of try and catch 2
// Date 20:30 29/10/2016
// By Ben a.k.a DreamVB

#include <iostream>

using namespace std;
using std::cout;
using std::endl;

int main(int argc, char *argv[]){
	double a = 0.0;
	double b = 0.0;
	double result = 0.0;

	cout << "Enter two numbers to be divided : ";
	cin >> a >> b;

	try{
		//Try and calc
		result = (a / b);
		//Test if second number is zero if so throw error.
		if (b == 0){
			throw "Division by zero found.";
		}
		cout << "Answer : " << result << endl;
	}
	catch (const char message[]){
		//Show error message.
		cout << message << endl;
	}

	system("pause");
	return 0;
}