Facebook
From aa, 7 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 418
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. { string s;
  5. int c=0,myvariable;
  6. level:
  7.  
  8. cout<<"enter any string: ";
  9. cin>>s;
  10. if( (s[0]>='a'&&s[0]<='z')||(s[0]>='A'&&s[0]<='Z')||(s[0]=='_') )
  11.  {
  12.    for(int i=1;i<s.length();i++)
  13.    {
  14.  
  15.      if((s[i]>='a'&& s[i]<='z')||(s[i]>='A' && s[i]<='Z')||(s[i]>='0'&& s[i]<='9')||(s[i]=='_') )
  16. {
  17.  c++;
  18. }}
  19. if(c==s.length()){
  20. myvariable=0;
  21. }}else
  22. {myvariable=1;
  23. }
  24. if(myvariable==1)
  25. cout<<s<<"is not valid identifier"<<endl;
  26. else
  27. cout<<s<<" is valid identifier"<<endl;
  28. goto level;
  29. return 0;
  30. }
  31.