Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Let the variable A be an integer, F be a real number type, and I be a double precision type. What is the data type of the expression 10+'a'+i*f?
Let the variable A be an integer, F be a real number type, and I be a double precision type. What is the data type of the expression 10+'a'+i*f?
Because the operator * has a higher priority than+and-,and the arithmetic operation is left-related, i*f is done first. In C language, when performing arithmetic operations on different types of variables, variables of float type should be unconditionally converted into double types. In this way, f is converted into double (double precision type) and multiplied by I, which is also double (double precision type), and the value of double (double precision type) is obtained. Then calculate 10+'a'. Because' a' is a character, and C language rules, character data must be unconditionally converted into int (plastic) when participating in arithmetic operations. So 10+'a' is an integer. Finally, add the value of 10+'a' to I * F, where 10+'a' is an integer and i*f is a double precision. Because double is higher than integer, the integer variable automatically becomes double. The sum of two double numbers is still double. char->; int->; Unsigned-> long->; The reason why double & lt transforms -float is to make the result as accurate as possible.