Skip to content

imparthgalani/Demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Demo

C program to test whether a given identifier is valid or not

#include <stdio.h>

#include <conio.h>

#include <ctype.h>

void main()

{

    char a[10];

    int flag, i = 1;

    clrscr();

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

    gets(a);

    if (isalpha(a[0]))

        flag = 1;

    else

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

    while (a[i] != '\0')

    {

        if (!isdigit(a[i]) && !isalpha(a[i]))

        {

            flag = 0;

            break;
        }

        i++;
    }

    if (flag == 1)

        printf("\n Valid identifier");

    getch();
}

Releases

No releases published

Packages

No packages published

Languages