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: www.beecrowd.com.br