Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishak798 authored Feb 14, 2024
1 parent 5d44791 commit b947059
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions OOPS/exception.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <bits/stdc++.h>
using namespace std;
int main()
{
try
{
/* code */
int age;
cout << "Enter your age: ";
cin >> age;
if (age >= 18)
{
cout << endl
<< "Access granted you are old enough.";
}
else
{
throw(age);
}
}
catch (int num)
{
cout << endl
<< "Access Denied - you must be at least 18 years old. ";
cout << endl
<< "Age is: " << num;
}
return 0;
}

0 comments on commit b947059

Please sign in to comment.