Char Functions

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

SRON provides 9 functions for this:

  • ascii()

  • isalphabet()

  • 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

{
    name : MAIN

    Bool val = isalphabet('z')
    println(val)

    val = isalphabet('@')
    println(val)

}

OUTPUT:

true false


3. isconsonant():

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

{
    name : MAIN
    
    Bool val = isconsonant('z')
    println(val)

    val = isconsonant('A')
    println(val)

}

OUTPUT:

true false


4. isdigit():

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

{
    name : MAIN
    
    Bool val = isdigit('A')
    println(val)

    val = isdigit('1')
    println(val)

}

OUTPUT:

false true


5. islower():

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

{
    name : MAIN
    
    Bool val = islower('z')
    println(val)

    val = islower('@')
    println(val)

}

OUTPUT:

true false


6. isupper():

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

{
    name : MAIN
    
    Bool val = isupper('Z')
    println(val)

    val = isupper('@')
    println(val)

}

OUTPUT:

false true


7. isvowel():

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

{
    name : MAIN
    
    Bool val = isvowel('A')
    println(val)

    val = isvowel('t')
    println(val)

}

OUTPUT:

true false


8. tolower():

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

{
    name : MAIN
    
    Char val = tolower('S')
    println(val)
}

OUTPUT:

s


9. toupper():

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

{
    name : MAIN
    
    Char val = toupper('a')
    println(val)
}

OUTPUT:

A


Last updated