Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define PI 3.14159265358979323846
- int main(void){
- double a,r,theta;
- printf("R = ?");
- scanf("%lf", &r);
- printf("θ = ?");
- scanf("%lf", &theta);
- a = 2 * r * sin(PI * theta / 180);
- /*
- sin,cos,tanの()の中身はラジアンとみなされるので適切に変換する必要がある
- ちなみにmath.hをincludeするとM_PIで円周率がすでに定義されてるよ
- */
- printf("a = %6.2f\n", a);
- return 0;
- }
- /*
- math.hをincludeしたプログラムをコンパイルする際は引数に -lm を与えること
- 例)cc sample.c -lm
- */
Add Comment
Please, Sign In to add comment