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?
can

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:

# Contains? & ltstdio.h & gt

int? Master ()

{

int? a = 10;

Double? s = 0.0 1;

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

Return? 0; ?

}

/*

Running results:

0. 10

*/