In the line indicated below I get the error, "invailid operands to binary expression ('float' and 'float). I'm trying to display the radians as "pi radians" for example when the input sides is 4. The output sum of interior angles is 2 pi radians. How can I get rid of this error and accomplish my goal? Thanks for reading.
#include <iostream>
#include <string>
using namespace std;
int main()
{
int sum_angle;
int num_sides;
int r_d; // radians/degrees
char R; //input radians
float radian;
int radian_pi;
float pi=3.14;
cout << "Basic Geometry with c++";
cout << "\n-----------------------\n";
cout << "Enter the number of sides of your polygon (3-10) :\n";
cin >> num_sides;
cout << "display options:\n";
cout << " - Type R for radians\n";
cout << " - Type anything else for degrees\n";
cin >> R;
sum_angle = (((num_sides)-2)*180);
radian = (sum_angle*pi/180);
radian_pi = (radian%pi); // <-- this line is the problem
if (R=='R')
{
cout << "The sum of interior angles in your polygon is:" << radian_pi << "radians";
cout << "\nA polygon with " << num_sides << " sides is called a ";
}
else
{
sum_angle=(((num_sides)-2)*180);
cout << "The sum of interior angles is:"<< sum_angle;
cout << "\nA polygon with " << num_sides << " sides is called a ";
}
if (num_sides==3)
cout << "triangle";
if (num_sides==4)
cout << "quadrilateral or tetragon";
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
int sum_angle;
int num_sides;
int r_d; // radians/degrees
char R; //input radians
float radian;
int radian_pi;
float pi=3.14;
cout << "Basic Geometry with c++";
cout << "\n-----------------------\n";
cout << "Enter the number of sides of your polygon (3-10) :\n";
cin >> num_sides;
cout << "display options:\n";
cout << " - Type R for radians\n";
cout << " - Type anything else for degrees\n";
cin >> R;
sum_angle = (((num_sides)-2)*180);
radian = (sum_angle*pi/180);
radian_pi = (radian%pi); // <-- this line is the problem
if (R=='R')
{
cout << "The sum of interior angles in your polygon is:" << radian_pi << "radians";
cout << "\nA polygon with " << num_sides << " sides is called a ";
}
else
{
sum_angle=(((num_sides)-2)*180);
cout << "The sum of interior angles is:"<< sum_angle;
cout << "\nA polygon with " << num_sides << " sides is called a ";
}
if (num_sides==3)
cout << "triangle";
if (num_sides==4)
cout << "quadrilateral or tetragon";
if (num_sides==5)
cout << "pentagon";
return 0;
}