sin()
We will get sin value of any number by using sin()
function.
sin(x)
x = angular value in radian ( not in degree )
We will declare PI as constant as radian input value.
Example sin()
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
int main(void){
float x,ret;
x=90; // input in degree
ret=sin(x*PI/180);
printf("sing(x)=%.1f", ret);
return 0;
}
The above code will give this output.
sin(x)= 1.0
Example cos()
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
int main(void){
float x,ret;
x=180;
ret=cos(x*PI/180);
printf("cos(%.0f)=%.2f",x, ret);
return 0;
}
Output
cos(180)=-1.00
Example tan()
#include <stdio.h>
#include <math.h>
#define PI 3.14159265
int main(void){
float x,ret;
x=45;
ret=tan(x*PI/180);
printf("tan(%.0f)=%.2f",x, ret);
return 0;
}
Output
tan(45)=1.00
This article is written by plus2net.com team.
plus2net.com