Pointers in C (II)¶
Character counter (2p)¶
Write a function that counts the vowels and consonants from a given character array and writes the counts into an uint8_t array given as a pointer.
Use the prototype
void charcounter(char *str, uint8_t *result);
, where result
is a pointer to a 2 elements array of type uint8_t [vowels, consonants]
.In this exercise we will define the vowels as
a, e, i, o, u
and assume the rest of the alphabet is consonants.The function has to be able to count upper- and lowercase letters, and ignore commas and other special characters.
Hints
Messages
Give feedback on this content
Was this task useful for learning?
Comments about the task?
Mean list (2p)¶
Make a function that finds the arithmetic mean of the given comma separated list of integers.
Example: The mean of the character array
"201,53,12,31,5"
is 60.4.Use the prototype
float mean(char *list);
Hint. The function
strtok
might be very useful.
Hints
Messages
Give feedback on this content
Was this task useful for learning?
Comments about the task?