Programming
Python
R
Java
C
C++
C#
WEB
HTML
CSS
JavaScript
BootStrap4
jQuery
SVG
MORE
Examples1
Python
GO
R
Java
C
C++
C#
Examples2
Python
R
Java
C
C++
C#
HTML
CSS
JavaScript
BootStrap4
jQuery
SVG
Seo Tools
Code Minifier
Code Beautifier
Language Compiler
Misc Tools
File Converter
References
C
C++
Python
Java
PHP
JavaScript
Examples
Python
R
Java
C
C++
C#
HTML
CSS
JavaScript
BootStrap4
jQuery
SVG
Home
About
Contact
JetPack
Multi Themes-->>
Code it ALL
Scroll TOP
Verifying age in C++ - CodeGK
Δ Cpp Examples
Try_except
Verifying age in C++
Checking Id in C++
While_loop
Calculate Sum of natural Numbers by While Loop in C++
Finding Euler's Series value using While Loop in C++
If_else
C++ If
++ Else
C++ Else-If
Syntax
C++ Syntax
C++ Syntax Error
Print
String Printing in C++
Number Printing in C++
Subtraction Printing in C++
Casting
Float to Int in C++
Int to Float in C++
Int to String in C++
String to Int in C++
Float to String in C++
String to Float in C++
Char
C++ Char
For_loop
Square number Iteration in C++
Calculating Factorial with For Loop in C++
Arrays
Declaring an Array in C++
Initializing an Array in C++
Strings
C++ String Concatenation
C++ String Append
C++ String Length
C++ String Accessing
Comments
Single-Line Comments in C++
Multi-Line Comments in C++
Double
Double in C++
Structures
C++ Structures
Vectors
push_back() in vectors C++
pop_back() in vectors C++
empty() in vectors C++
size() in vectors C++
Float
Float in C++
Break
Break out of For Loop in C++
Break out of While Loop in C++
Int
Integer in C++
Continue
Continue in For Loop in C++
Continue in While Loop in C++
Function
Adding Two Numbers with Function in C++
alculating Factorial of a number with Recursion in C++
Operators
Comparison Operators in C++
Arithematic Operators in C++
Assignment Operators in C++
Logical Operators in C++
Booleans
C++ Booleans
♦ Verifying age in C++
♣ Example1: Verifying age in C++
In this example, Person with age 14 is restricted from entering the PUB.
Example
Input:
Run CODE
Reload Code
Copy Code
#include
using namespace std; int main(){ try { int age = 14; if (age > 21) { cout << "You can enter the PUB."; } else { throw (age); } } catch (int uage) { cout << "You must be atleast 21 to enter the PUB"<
Output:
Try_except
Verifying age in C++