Different algorithms in C