Given a number N(where N <= 50), the task is to find the value of Pi (Π) up to N decimals places.
Input: N = 2
Input: N = 10
- The value of Π is calculated using acos() function which returns a numeric value between [-Π, Π].
- Since using acos(0.0) will return the value for 2*Π. Therefore to get the value of Π:
double pi = 2*acos(0.0);
- Now the value obtained from above equation is estimated to N decimal digit as:
printf("%.*lf\n", N, pi);
Below is the implementation of the above approach:
Time Complexity: O(1)
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Program to compute division upto n decimal places
- Convert Decimal To Hexa-Decimal including negative numbers
- Find the sum of digits of a number at even and odd places
- Check whether sum of digits at odd places of a number is divisible by K
- Arrangement of the characters of a word such that all vowels are at odd places
- Total number of ways to place X and Y at n places such that no two X are together
- Primality test for the sum of digits at odd places of a number
- Check whether product of digits at even places of a number is divisible by K
- Count of numbers in range which are divisible by M and have digit D at odd places
- Check if product of digits of a number at even and odd places is equal
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- 10's Complement of a decimal number
- BCD addition of given Decimal numbers
- 9's complement of a decimal number
- BCD or Binary Coded Decimal
- Lex program for Decimal to Hexadecimal Conversion
- Convert a given Decimal number to its BCD representation
- Exponential notation of a decimal number
- C Program for Decimal to Binary Conversion
- Program for Decimal to Binary Conversion
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : AnkitRai01