Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Can integers be operated with floating-point numbers in C language?
Can integers be operated with floating-point numbers in C language?
C language can operate integer and floating-point numbers.

In C language, when the number of different data types is mixed, the automatic conversion of data types will occur, which is automatically completed by the compilation system. Automatic conversion follows the following rules:

1. If the operands involved are of different types, first convert them to the same type, and then perform the operation.

2. Transform in the direction of increasing the data length to ensure that the accuracy does not decrease.

So integers can be calculated by floating-point numbers.

Reference code:

# include & ltstdio.h & gt;

int main();

{;

int a = 10;

Double s = 0.01;

printf("%.2lf\n ",s * a);

Returns 0; ?

};

/*;

Running results:

0. 10;

*/。