Note during coding Don't use %lf in printf, this may be wrong in c compilers before c99. must be aware that float is not accurate, we can use int when need accurate value.