#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
int main()
{
clrscr();
int flag=0;
char state = '0';
char ch = NULL;
char token[10]={NULL};
char stt[6][4] = { NULL,'7','8','9',
'0','1','2','3',
'1','1','1',NULL,
'2',NULL,'2','3',
'3',NULL,'4',NULL,
'4',NULL,'4',NULL };
cout << "Enter Identifier, Integer or Real Number : ";
cin >> token;
for(int i=0; i < strlen(token); i++)
{
if (isalpha(token[i]))
ch='7';
elseif (isdigit(token[i]))
ch = '8';
elseif (token[i] == '.')
ch = '9';
for(int j=1; j<=3 && ch != stt[0][j]; j++);
for(int k=1;k<=5 && state != stt[k][0];k++);
state = stt[k][j];
if(state == NULL)
{
cout << endl << "Invalid ....";
flag=1;
break;
}
}
if (flag==0)
cout<<"valide string";
getch();
return 0;
}