Identifier validation
Time Limit: 0.5 sec
The Problem
In C programming, identifiers are names given to C entities, such as variables, functions, structures etc. Identifier are created to give unique name to C entities to identify it during the execution of program. For example:
int num1;
int num_2;
Here, num1 is a identifier which denotes a variable of type integer. Similarly, num_2 is another identifier, which denotes another variable of type integer.
Rules for writing identifier
1. An identifier can be composed of letters (both uppercase and lowercase letters), digits and underscore '_' only.
2. The first letter of identifier should be either a letter or an underscore. But, it is discouraged to start an identifier name with an underscore though it is legal. It is because, identifier that starts with underscore can conflict with system names. So, underscores (_) will appear only in the middle and never two consecutively.
Write a program to read a string and output whether it is a valid or invalid identifier.
The Input
Input starts with an integer T(1<=T<=100), denoting the number of test cases. Each test case contains string S. Maximum length of the string 20.
The Output
For each test case, print "Case X: Valid" or "Case X: Invalid" here X is the case number stating from 1.
Sample Input
4
abc_3
abc def
a_bc
abc_
Sample Output
Case 1: Valid
Case 2: Invalid
Case 3: Valid
Case 4: Invalid
Problem Setter: Shahin ShamS