Can you rewrite this program in C or C++?