Savings Algorithm in C language