Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1?

Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1?

 

A. rem = 3.14%2.1;

B. rem = fmod(3.14, 2.1);

C. rem = modf(3.14, 2.1);

D. Remainder cannot be obtain in floating point division.

Hướng dẫn

Chọn B là đáp án đúng

Xem lời giải

Xem lời giải

Toán tử % lấy phần dư của phép chia 2 số nguyên. Hàm fmod() lấy phần dư của phép chia 2 số thập phân. Hàm modf() tách phần nguyên và phần thập phân.

Tags: