Hello friends how are you, today in this blog i will teach you what is math function, different types of math function, how math function works and many programs of math function in a very simple way.
Let's start
2.There are many predefined math function in C library.
3.All the math functions are predefined in math.h header file.
👉Math Function
Function name | Description |
sin() | It is used to calculate the sine value. |
sinh() | It is used to calculate hyperbolic sine value. |
cos() | It is used to calculate the cosine value. |
cosh() | It is used to calculate hyperbolic cosine value. |
tan() | It is used to calculate the tangent value. |
tanh() | It is also used to calculate the hyperbolic tangent value. |
sqrt() | It is used to calculate square root of value passed to the function. |
pow() | It is used to calculate the power of a number pow(base,power). |
exp() | It is used to calculate the exponential of the value passed to the function. |
log() | It is used to calculate natural logrithm. |
log10() | It is used to calculate base-10 logrithm. |
floor() | It always returns minimum round off value. |
ceil() | It always returns maximum round off value. |
round() | It returns maximum round off value if the input value is greater than or equal to center value otherwise minimum round off value. |
abs() | It always returns positive value. |
fmod() | It is used to convert all the character into lower alphabet. |
👉Example
#include<stdio.h> #include<conio.h> #include<math.h> int main() { float a=2; printf("sin(2)=%f\n",sin(a)); printf("cos(2)=%f\n",cos(a)); printf("tan(2)=%f\n",tan(a)); printf("exp(2)=%f\n",exp(a));//exponential printf("log(2)=%f\n",log(a));//natural log printf("log10(2)=%f\n",log10(a));//log10 printf("sqrt(4)=%f\n",sqrt(4));//square root printf("cbrt(27)=%f\n",cbrt(27));//cube root return 0; } ### Output ### sin(2)=0.909 cos(2)=-0.416 tan(2)=-2.185 exp(2)=7.389 log(2)=0.693 log10(2)=0.301 sqrt(4)=2 cbrt(27)=3
It returns the minimum round off value.
#include<stdio.h> #include<conio.h> #include<math.h> int main() { printf("%f\n",floor(2.3)); printf("%f\n",floor(2.5)); printf("%f\n",floor(2.8)); return 0; } ### Output ### 2.0 2.0 2.0
It returns the maximum round off value.
#include<stdio.h> #include<conio.h> #include<math.h> int main() { printf("%f\n",ceil(2.3)); printf("%f\n",ceil(2.5)); printf("%f\n",ceil(2.8)); return 0; } ### Output ### 3.0 3.0 3.0
#include<stdio.h> #include<conio.h> #include<math.h> int main() { printf("%f\n",round(2.3)); printf("%f\n",round(2.5)); printf("%f\n",round(2.8)); return 0; } ### Output ### 2.0 3.0 3.0
Request:-If you found this post helpful then let me know by your comment and share it with your friend.
If you want to ask a question or want to suggest then type your question or suggestion in comment box so that we could do something new for you all.
If you have not subscribed my website then please subscribe my website. Try to learn something new and teach something new to other.
Thanks.😊
0 Comments