Question: Bonus Problem: Digits of Pi (pi.c) Write a program that will read in the first million digits of the mathematical constant pi from a


Bonus Problem: Digits of Pi (pi.c) Write a program that will read in the first million digits of the mathematical constant pi from a text file and output the number of occurrences of each digit. A text file named pi_million.txt containing the first million digits of pi will be provided for you. You should output both the number of occurrences of each digit and percentage of occurrences. Since pi is an irrational number if we could take an infinite number of digits after the decimal place we should see identical instances of each of the digits from 0 to 9. However, since we are limited to a finite number of digits, each digit will only approximately equal to 10% of the digits displayed. You may use any design for your program that you deem appropriate including whatever functions you think helpful to write. Your program is expected to read the pi digits from the text file pi_million.txt as follows: fopen("pi_million.txt","r"); Sample Output: Number of 0 is: 99959 Number of 1 is: 99757 Number of 2 is: 100026 Number of 3 is: 100229 Number of 4 is: 100230 Number of 5 is: 100359 Number of 6 is: 99548 Number of 7 is: 99800 Number of 8 is: 99985 Number of 9 is: 100106 The percentage occurrence of 0 is 9.995910 % The percentage occurrence of 1 is 9.975710 % The percentage occurrence of 2 is 10.002610 % The percentage occurrence of 3 is 10.022910 % The percentage occurrence of 4 is 10.023010 % The percentage occurrence of 5 is 10.035910 % The percentage occurrence of 6 is 9.954810 % The percentage occurrence of 7 is 9.980010 % The percentage occurrence of 8 is 9.998510 % The percentage occurrence of 9 is 10.010610 % Total percentage is: 100.000000 Data Type Requirement: The digit count should be of type long and the percentages should be doubles. You have to submit the following file containing the solution of this program via handin: pi.c
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
