Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

I need help in C Programming?

I am writing an if condition

it is if(value is not an alphabetic character){

do something

regards

}

I dont know any efficient way of doing it. I can do that but it will be so long

if(value!='a'||value!='b'...............value!='z')

{body}

Does anyone know how to write a condition to exclude all alphabetic characters

3 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    This will do it.

    if (!(((value >= 'a') && (value < = 'z')) ||

    ((value >= 'A') && (value < = 'Z'))))

  • 1 decade ago

    The best way to do this is:

    if ( ! isalpha ( value ) )

    isalpha is the ISO standard function from ctypes.h that tells you whether the character is alphabetic.

    You can write a test like ('a'<=value && value<='z') || ('A'<=value && value<='Z') but that is of limited use and shouldn't make it into commercial software. It's fine in Italy for Italian words, but anywhere like the UK or USA where there is the occassional use of accented or non-Roman letters it fails (e.g. Beyoncé with an é at the end).

  • 1 decade ago

    yeah dude..:)

    * you can get the value as an integer datatype and check it whether the inputted data ranges from ASCII code of alphabets(i.e., from A to Z and from a to z)

    check it out..:):)

Still have questions? Get your answers by asking now.