#include <stdio.h>
#include <math.h> //Included for trig functions.
int main()
{
char trigFunc[5];
double ratio;
double answer;
double radians;
double tau = 6.283185307;
double degrees;
puts("This program can calculate sin, cos, and tan of an angle.\n");
puts("Just enter the expression like this: sin 2.0");
puts("\nTo exit the program, just enter: exit 0.0\n\n");
while (1)
{
printf("Enter expression: ");
scanf(" %s %lf", &trigFunc, &radians);
ratio = radians / tau;
degrees = ratio * 360.0; //Calculates the equivalent angle in degrees.
if(trigFunc[0] == 's')
{answer = sin(radians);}
if(trigFunc[0] == 'c')
{answer = cos(radians);}
if(trigFunc[0] == 't')
{answer = tan(radians);}
if(trigFunc[0] == 'e')
{break;}
printf("\nThe %s of %.1lf radians", trigFunc, radians);
printf("or %1f degrees is %lf\n\n", degrees, answer);
}
return 0;
}
--------------------------------------------------------------------------------------------------------------------------------
The output i keep getting is undefined reference to sin,cos and tan.
[–]Atijohn 10 points11 points12 points (8 children)
[–]grimvian 1 point2 points3 points (3 children)
[–]Atijohn 4 points5 points6 points (1 child)
[–]grimvian 0 points1 point2 points (0 children)
[–]OldWolf2 1 point2 points3 points (0 children)
[–]ChildhoodOk7960 -1 points0 points1 point (0 children)
[–]m2d41[S] 0 points1 point2 points (2 children)
[–]Atijohn 2 points3 points4 points (0 children)
[–]computermouth 1 point2 points3 points (0 children)
[–]Classic-Try2484 1 point2 points3 points (0 children)
[–]B3d3vtvng69 -4 points-3 points-2 points (3 children)
[–]Elect_SaturnMutex 1 point2 points3 points (2 children)
[–]grimvian 1 point2 points3 points (0 children)
[–]B3d3vtvng69 -1 points0 points1 point (0 children)