Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please explain what this code means. How would the results differet from expectations? #include #include using namespace std; #ifndef M_PI #define M_PI (4.0 * std::atan2(1.0,
Please explain what this code means. How would the results differet from expectations?
#include
#include
using namespace std;
#ifndef M_PI
#define M_PI (4.0 * std::atan2(1.0, 1.0))
#endif
int main() {
int ngon = 3;
double insngon = 0.0 ;
double cirngon = 0.0;
cout << "N" << "\t\t\t" << "ins-ngon" << "\t\t\t" << "cirngon" << "\t\t" << " ";
while(ngon <= 30)
{
insngon = 2*ngon*sin(M_PI/ngon);
cirngon = 2*ngon*tan(M_PI/ngon) ;
printf("%d\t\t %.14lf\t\t%.14lf ",ngon,insngon,cirngon);
ngon++;
if(cirngon-insngon <= pow(10.0,-15)) break;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started