Count of alphabets having ASCII value less than and greater than k | C # implementation of the above approach ; Function to count the number of characters whose ascii value is less than k ; Initialising the count to 0 ; Incrementing the count if the value is less ; return the count ; Driver code
using System ; class GFG { static int CountCharacters ( String str , int k ) { int cnt = 0 ; int len = str . Length ; for ( int i = 0 ; i < len ; i ++ ) { if ( ( ( int ) str [ i ] ) < k ) cnt ++ ; } return cnt ; } public static void Main ( ) { String str = " GeeksForGeeks " ; int k = 90 ; int count = CountCharacters ( str , k ) ; Console . WriteLine ( " Characters ▁ with ▁ ASCII ▁ values " + " less ▁ than ▁ K ▁ are ▁ " + count ) ; Console . WriteLine ( " Characters ▁ with ▁ ASCII ▁ values ▁ greater " + " than ▁ or ▁ equal ▁ to ▁ K ▁ are ▁ " + ( str . Length - count ) ) ; } }