forum.venkateswarlu.net
      Register      Login
Program to calculate pi value(22/7)

1 replies to this topic

Laxman B #1
Member
42 Points
Posted on 22 Sep 2014 01:08 PM IST
  double a = 22;
        double b = 7;
       // double result = a / b;

        double temp = 0;
        string c = "";
        int a1 = 0;
string objResult="";

        while (temp > 0)
        {
            if (a1 == 0)
            {
                temp = a % b;
                a1 = (int)(a / b);
                objResult = a1.ToString() + ".";
                a1++;
            }
            else
            {
                c = temp.ToString() + "0";
                temp = Convert.ToInt32(c) % 7;
                a1 = Convert.ToInt32(c) / 7;
                objResult = objResult + a1.ToString();
            }

Note: It runs infinite time, please stop the process
 
C#.NET     1242 views     Reply to this topic
Kamalesh Kumar #2
Member
30 Points
Replied on 18 Feb 2016 12:34 PM IST When kicking off in mathematics, students are introduced to pi as a price of three.14 or 3.14159. tho' it's associate degree real number, some use rational expressions to estimate pi, like 22/7 of 333/106. These rational expressions square measure solely correct to a handful of decimal places, however.
 The primary 100 digits of pi are:

3.14159 26535 89793 23846 26433 83279 50288 41971 69399 37510 58209 74944 59230 78164 06286 20899 86280 34825 34211 7067
Pi has been well-known for nearly 4000 years and was discovered by ancient Babylonians. A pill from somewhere between 1900-1680 B.C. found pi to be three.125. the traditional Egyptians were creating similar discoveries, as proven by the Rhind Papyrus of 1650 B.C. during this document, the Egyptians calculated the realm of a circle by a formula giving pi associate degree approximate price of three.1605. 
Reply to this topic