Char Functions

These function are used to work on 'Char' type values.

SRON provides 9 functions for this:

  • ascii()

  • isAlphabet()

  • isAlphaNum()

  • isConsonant()

  • isDigit()

  • isLower()

  • isUpper()

  • isVowel()

  • toLower()

  • toUpper()


1. ascii():

To get the ASCII number of a 'Char' value or you want to get the character value of a ASCII number, then this function is used.

{
    name : Main

    @ if you pass a 'Char' value,then this
    @ function will return the ASCII number
     Int val = ascii('A')
     println(val)

    @ if you pass a 'Int' value, then this 
    @ function will return its 'Char' value
     val = ascii(122)
     println(val)

}

OUTPUT:

65 z


2. isAlphabet():

This functions checks if the passed 'Char' type value is an alphabet or not

OUTPUT:

true false


3. isAlphaNum():

This functions checks if the passed 'Char' type value is an alpha-numeric character or not.

OUTPUT:

true true false


4. isConsonant():

This function checks if the passed 'Char' type value is a consonant or not

OUTPUT:

true false


5. isDigit():

This function checks if the passed 'Char' type value is digit or not

OUTPUT:

false true


6. isLower():

This function returns true if the passed 'Char' type value is in lower case otherwise returns false.

OUTPUT:

true false


7. isUpper():

This function returns true if the passed 'Char' type value is in upper case otherwise returns false.

OUTPUT:

true

false


8. isVowel():

This function is used to check if the passed 'Char' value is a vowel or not.

OUTPUT:

true false


9. toLower():

This function converts the passed 'Char' value to lower case.

OUTPUT:

s


10. toUpper():

This function converts the passed 'Char' value to upper case.

OUTPUT:

A


Last updated