I recently searched long and hard on the internet for source code in C language to do a runs up and down test on a sequence of numbers to test whether it was a sequence of random numbers. I found very little. The couple of programs had, to me, very opaque and incomprehensible code. So I wrote my own code. Here is a link to my C language source code:
I hope it is comprehensible to others — I've included quite a few comments in the code to try to make it so. The download consists of a C++ program (actually it's just C) for doing the test and an error function. Both are intended for Windows Visual Studio, but the test program should be very easily adaptable to other platforms. The error function might take more doing and it might be best to replace it with your own.