Average of ASCII values of characters of a given string | C ++ code to find average of ASCII characters ; Function to find average of ASCII value of chars ; loop to sum the ascii value of chars ; Returning average of chars ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int averageValue ( string s ) { int sum_char = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { sum_char += ( int ) s [ i ] ; } return sum_char / s . length ( ) ; } int main ( ) { string s = " GeeksforGeeks " ; cout << averageValue ( s ) ; return 0 ; }