Error of finding the area of a circle in the C language

Updated on technology 2024-02-09
8 answers
  1. Anonymous users2024-02-05

    If you define r as int, enter 10000 and that will automatically force the type conversion when multiplied.

    If r is defined as double, the significant digit accuracy of 10000 is not high enough.

    You can try not to change the type of r, and then instead of typing r, you can specify r= directly.

  2. Anonymous users2024-02-04

    The vast majority of decimals in the computer are imprecise, because all the numbers in the computer are represented by the complement of binary, for example, in the computer will be automatically converted to binary, as for the exact number of digits is related to the defined type, if it is float, the output will be accurate to 7 decimal places.

  3. Anonymous users2024-02-03

    The reason for this has been answered by wangfan2000 students.

    The double type precision is 8 bits, remember yes.

  4. Anonymous users2024-02-02

    The value of r is too large, causing s to be out of range, try with a small number.

  5. Anonymous users2024-02-01

    In the classic double problem, the data stored by the double is not the same as what you see. It is error-free. Try defining r as integer

  6. Anonymous users2024-01-31

    Note that the final result of the operation with different precision follows the high precision, so the result is like this, please refer to the section of the book "Mixing Actions between Various Types of Numerical Data" for details.

  7. Anonymous users2024-01-30

    Problems with data type accuracy differences and type coercion. The two upstairs spoke very well and should be praised.

  8. Anonymous users2024-01-29

    3 All (1) In terms of thinking, there is no problem.

    2) Logically, pi is generally taken as a decimal place, and if you define an int type, then it is very imprecise.

    3) In the final output statement, there are 4 formatters in the first double quotation marks, and only 3 variables in the back, which is inconsistent.

    Suggestions for modification: 1) Define the variables pi and radius r as float type (floating-point type, that is, it can be a decimal number), and the return value of the function for calculating the area is also defined as float type.

    2) Then the formatter corresponding to the float type is %f, which has been modified in scanf and printf.

    3) In the final output statement, complete the following variables, as follows:

    printf("area = %.2f * 2f * 2f = %.2f ",pi,r,r,area);

    %.2f means the number of output, with 2 decimal places left.

    If it helps, please click to adopt, thank you!

Related questions
12 answers2024-02-09

When passing in array parameters, int a[m][m] is used, where m cannot be a variable. >>>More

4 answers2024-02-09

#include

using namespace std; >>>More

11 answers2024-02-09

I feel very simple...

#include >>>More

7 answers2024-02-09

The crux of the question is what error is prompted? Is it a blue screen? >>>More

2 answers2024-02-09

Charles Darwin (1809-1882), an English biologist and the founder of the theory of evolution, made a five-year voyage around the world aboard the ship Beagle, made extensive observations and collections of plants, animals, and geological structures, and published the epoch-making work "The Origin of Species" in 1859, completing a revolution in biology >>>More