why it is printing as cout<<(4*(double)(r*r))<<endl;
as integer as something wrong with my typecast.
I have to take input r as an int
input->1 output->4
and why
cout<<setprecision(2)<<ab2<<endl;
rounding the answer at least it should give correct answer till two digits because i have set set precision 2
input->1 output->3.8
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
long long int r;
cin>>r;
double ab2 = 4*(double)(r*r) - double(0.25);
cout<<4*(double)(r*r)<<endl;
cout<<setprecision(2)<<ab2<<endl;
cout<<ab2+0.25<<endl;
}
}