Last active
June 27, 2016 15:27
-
-
Save guyhughes/1422d256c76a544608430cbd16c6ba62 to your computer and use it in GitHub Desktop.
trig in cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _USE_MATH_DEFINES | |
#include <cmath> | |
#include <iostream> | |
#include <cstdio> | |
using namespace std; | |
void trig(double angle, double *sine, double *cosine, double *tangent) | |
{ | |
angle = angle * M_PI / 180; | |
*sine=sin(angle); | |
*cosine=cos(angle); | |
*tangent=tan(angle); | |
} | |
int main ( void ) | |
{ | |
double sine,cosine,tangent; | |
double angle = 180; | |
trig(angle, &sine, &cosine, &tangent); | |
cout << angle << endl; | |
cout << "sin: " << sine << endl; | |
cout << "cos: " << cosine << endl; | |
cout << "tan: " << tangent << endl; | |
printf("%3.1f %3.1f %3.1f\n",sine,cosine,tangent); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trig: trig.cc | |
g++ -o trig trig.cc -Wall -Wextra -pipe -lm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment