Home > Back-end >  C language teachers advice please.
C language teachers advice please.

Time:10-24

Int type is converted to a float behind decimal why haven't you?

How should I accurate output?

CodePudding user response:

No problem, turn the decimal integer was like this,

CodePudding user response:

Because your S is defined as an integer, when calculating the area of assignment statements on the right side of the expression type is the result of the double type, but there is an implicit conversion into integer assigned to the S, in the variable S memory is stored in the integer data, when the output is strong to float, is conducted on the basis of integer S coercion,

CodePudding user response:

Int s with a double s

CodePudding user response:

The integer s converted to floating point is you the result

CodePudding user response:

S=r * r * p; This statement execution time already remove the decimal point. Because s definition is of type int, there is no the decimal part of type int.

CodePudding user response:

The
reference 5 building self-confidence boy reply:
s=r * r * p; This statement execution time already remove the decimal point. Because s definition is of type int, there is no the decimal part of type int.

Understand, thank you
  • Related