Various codes in C++ and C