Question: Write a program to read from the user a single line ( up to 2 5 5 characters ) at a time and splits the

Write a program to read from the user a single line (up to 255 characters) at a time and splits the line into lexemes, if possible. The program will determine whether each lexeme is a reserved word, an arithmetic operator, a special symbol, a number, or an identifier. The following arrays are already given:
char reservedWord[4][10]={cin>>,for,int,while};
char operator[6][2]={+,-,*,/,++,--}
char specialSymbol[7][3]={>,=,;,(,),>=,,,{,}};
A number is an unsigned integer or a signed integer.
An identifier starts with a letter or _ followed by any number of letters, _, and digits, and excludes any reserved word.
For each lexeme check whether it is a reserved word. If not, check whether it is a special symbol. If not, check whether it is a number. If not, check whether it is an operator. If not, check whether it is an identifier. If none of these, display invalid. The program must be case insensitive. Save it as Prog3.Sample I/O:
Enter a statement:
Enter a statement: int j=-1; while (j10){cin>> myTime ;j++;
int reserved word
j, identifier
=, special symbol
-1, number
; special symbol
while reserved word
( special symbol
j, identifier
, invalid
10 number
special symbol
special symbol
cin >> reserved word
myTime identifier
; special symbol
j, identifier
++, operator
; special symbol
} special symbol
CONTINUE (yn)?n
 Write a program to read from the user a single line

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!