0
Why const double pi is used? Why cant i put const pi=3.1 instead of 3.14 ?? Pls answer
2 odpowiedzi
+ 3
You can choose to not declare the variable and write 3.142 in place of the variable, but writiing pi in place of the literal value makes your code better in terms of readability. From a reader's perspective, semantics matter.
+ 1
hi,
because py is a very special number (never ended) and use for lot of important maths equations.
So, we need something more precise but not too long to kill your self when you calculate.
try to calculate perimeter or surface of a circle with 3.1 and after with 3.14 and after with 3.2, look the difference.