TRY AND CATCH FOR VOTING
#include<iostream>
using namespace std;
int main()
{
int age;
cout<<"enter the age"<<"\n";
cin>>age;
try
{
if(age<=18)
throw "not eligible to vote";
cout<<"eligible to vote";
}
catch(const char *ch)
{
cout<<"age lesser"<<ch;
}
}
Comments
Post a Comment