Dun radius of circumference R. Write a long-term program... I don't know what a mistake is.



  • I'm going to stepic, there's a mission: Dun radius of circumference R. Write a program for the length and area of the area. Consider that the radius is a substance number and P = 3.14. The answer shall be accurate to 2 figures after the comma.

    He wrote the following code:

    #include <iostream>
    #include <cmath>
    using namespace std;
    

    int main()
    {
    float R, pi=3.14, length, s;
    cin >> R;
    length = (pi*2)R;
    R = pow(R, 2);
    s = (pi)
    (R);

    cout &lt;&lt; length &lt;&lt; " " &lt;&lt; s;
    
    return 0;
    

    }

    But the test doesn't go through. What's the problem with the code?



  • The step is clearly written:

    The accuracy is as follows:
    cout << fixed << setprecision(i) << x
    where i is the number of figures after the comma for expression x.

    And the code.

    cout << fixed << setprecision(2) << length << " " << s;
    

    It's quite a test. ♪ ♪


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2