Average Character
Last updated
Last updated
The basic idea is easy, just to get the average ASCII value of each character in the input string.
However, if C is the language being used, things get a bit tricky regarding the input. Here, we can only use fgets()
to read the input because white space characters cannot be ignored in this question. So, the correct way to read the input is below:
Here the MAX_LEN
is 2 characters more than 100 (the actual length of the string). This is because:
Add 1 to take the null character into account (the property of string in C)
Add 1 to take the \n
character which is read by fgets()
(the property of fgets()
in C)