#include <stdio.h>
#include <iostream.h>
#include <string.h>
#include <ctype.h>
#include <process.h>
int main()
{
char stt[4][4] = { NULL, '3', '4', '5',
'0', '1', NULL, '2',
'1', '1', '2', '2',
'2', '1', '2', '2'};
char ch;
char state = '0';
char variable[20];
cout<<"Input variable name in c : ";
cin>> variable;
for(int i=0; i<20 && variable[i] != NULL; i++)
{
if(isalpha(variable[i]))
{
ch = '3';
}
elseif(isdigit(variable[i]))
{
ch = '4';
}
elseif(variable[i] == '_')
{
ch = '5';
}
for(int j=1; stt[0][j] != ch; j++);
for(int k=1; stt[k][0] != state; k++);
state = stt[k][j];
if(state == NULL)
{
printf("Invalide variable name!!!!!!!!!!!");
getchar();
exit(0);
}
}
printf("%s","Valide variable name");
getchar();
return 0;
}