Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to specify the number of decimal places in c++

#include<bits/stdc++.h>
using namespace std;
int main ()
{
    double A, n, R, Square_of_R;
    cin >> R;
    Square_of_R = pow(R,2);
    n = 3.14159;
    A = n * Square_of_R;
    cout << "A=" << fixed << setprecision(4) << A << endl; 
  	//printf("A=%.4lf", A);
    return 0;
}
Source by www.beecrowd.com.br #
 
PREVIOUS NEXT
Tagged: #number #decimal #places
ADD COMMENT
Topic
Name
8+1 =