Computer Science, asked by pomrmarak3800, 1 year ago

Write a program in c to test wheather a given identifier is valid or not

Answers

Answered by Ammustic007
0
1. #include<stdio.h>

2. #include<conio.h>

3. #include<ctype.h>

4. void main()

5. {

6. char a[10];

7. int flag, i1=1;

8.clrscr();

9. printf("\n Enter an identifier:");

10. gets(a);

11. if(isalpha(a[0])) flag=1;

12. else

13. printf("\n Not a valid identifier");

14. while(a[i1]!='\0')

15. {

16. if(!isdigit(a[i1])&&!isalpha(a[i1]))

17. { flag=0;

18.  break;

19. }

20.  i1++;

21.  }

22.  if(flag==1)

23. printf("\n Valid identifier");

24. if(flag==0)

25. printf("\n invalid identifier");

26. getch();

27. }

Below is the output of the above code.


:)
Attachments:
Similar questions