Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!