Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A function that calls another function, which in turn calls the original functio

ID: 3657679 • Letter: A

Question

A function that calls another function, which in turn calls the original function, is said to be corecursive. Note that corecursive functions occur in pairs. Write a program that counts the number of alphabetic characters in a string and sums the digits in the string. For example, the string "AOis444apple7" has eight alphabetic characters, and the digits in the string sum to 19. Write a pair of corecursive functions to help carry out the tasks. Use count_alph() to count the alphabetic characters, and use sum_digit() for summing the digits. These two functions should call each other. For comparison, write a non-corecursive function that performs the two tasks in a direct, more natural fashion. Hint: If necessary, use static variables.

Explanation / Answer

#include #include #include int countAlpha(char *);// counts all alpha chars int sumDigits(char *);// finds digits and sums int main(void){ char s[]=("AOis444apple7"); //string being tested countAlpha(s);// calls string to alpha count } int countAlpha(char *s) { int i;//counter int countAlpha=0; for(i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote