-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lecture18 MathFunctions.c
69 lines (37 loc) · 1.05 KB
/
Lecture18 MathFunctions.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdio.h>
#include <stdlib.h>
//Written by Bunyamin Yavuz in 2022
//Mathematic functions
int main()
{
// Square root (sqrt)
float number1,result1;
printf("Enter a number: ");
scanf("%f",&number1);
result1 = sqrt(number1);
printf("Square root of %f is %.3f\n",number1,result1);
// Power (pow)
int base,power,result2;
printf("Enter the base and power respectively: ");
scanf("%d %d",&base,&power);
// pow(base,power)
result2 = pow(base,power);
printf("%d^%d = %d\n",base,power,result2);
// Absolute (fabs)
double number3,result3;
printf("Enter a number");
scanf("%lf",&number3);
result3 = fabs(number3);
printf("|%lf| = %lf",number3,result3);
// Sinus cosinus (sin) (cos)
double resultsin,resultcos,angle;
printf("Enter the angle: ");
scanf("%lf",&angle);
// Sin
resultsin = sin(angle);
printf("Sin(%lf) = %lf",angle,resultsin);
// Cos
resultcos = cos(angle);
printf("Cos(%lf) = %lf",angle,resultcos);
return 0;
}