// Given a string, compute recursively (no loops) the number of lowercase ‘x’
// chars in the string.
//
// countX(“xxhixx”) → 4 
// countX(“xhixhix”) → 3
// countX(“hi”) → 0
 
#include <stdio.h>
 
// To enable debug messages uncomment #define
#define TEST 1
 
int countX(char *s);
void startTesting();
 
int main(void) {
#ifdef TEST
    startTesting();
#endif
 
	return 0;
}
 
int countX(char *s) {
    if (*s == '\0') {
    	return 0;
    } else {
    	return ((*s == 'x' ? 1:0) + countX(++s));
    }  
}
 
void test1()
{
    int count = countX("xxhixx");
    printf("countX(\"xxhixx\") = %d\n", count);
}

void test2()
{
    int count = countX("xhixhix");
    printf("countX(\"xhixhix\") = %d\n", count);
}
 
void test3()
{
    int count = countX("hi");
    printf("countX(\"hi\") = %d\n", count);
} 
 
void startTesting()
{
    test1();
    test2();
    test3();
}