Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What is the addition of character type and floating point type in C language? What does it have to do with ASCII values?
What is the addition of character type and floating point type in C language? What does it have to do with ASCII values?
According to the principle of automatic conversion, the lower level is converted to the higher level, so the result after addition is the result of adding the ASCII values corresponding to the character type and the floating point type, and the result should be floating point type.

Because character types are actually stored in the form of ASCII values, which is the same as plastic, the corresponding ASCII values are used when numerical calculation is directly used, which is equivalent to the operation of plastic data and floating-point data.

Can give a simple example, easy to understand and verify, as follows:

# include & ltstdio.h & gt

void main(){

char a = ' m

Floating point b =12.32;

Printf ("the value of a is% c, and the value of b is %.2f\n\n", a, b);

Printf ("Output character data a (value m) is an integer: %d\n", a);

Printf(" a+b output is %.2f\n ",A+B);

}

Give it a try and see the result.