Math hquickissential

699 views

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
699
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
54
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Math hquickissential

  1. 1. Math.h <ul><li>Math.h is a header file declared before using basic mathemical operation such as </li></ul><ul><ul><li>Power (Squareroot, power) </li></ul></ul><ul><ul><li>Trigonometric(Sine, cosine, tangent) </li></ul></ul><ul><ul><li>Exponential and logarithmic (Log, exponential) </li></ul></ul><ul><ul><li>Rounding, Absolute value </li></ul></ul><ul><ul><li>Etc etc </li></ul></ul>
  2. 2. Power <ul><li>Power </li></ul><ul><ul><li>Example : x^y should be written as power(x,y); </li></ul></ul><ul><ul><li>Example in coding: </li></ul></ul><ul><li>#include <stdio.h> </li></ul><ul><li>#include <math.h> </li></ul><ul><li>int main (){ </li></ul><ul><li>printf (&quot;7 ^ 3 = %lfn&quot;, pow (7,3)); </li></ul><ul><li>printf (&quot;4.73 ^ 12 = %lfn&quot;, pow (4.73,12)); </li></ul><ul><li>printf (&quot;32.01 ^ 1.54 = %lfn&quot;, pow (32.01,1.54)); </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul>
  3. 3. Power <ul><li>Squareroot </li></ul><ul><ul><li>Example : x^y should be written as power(x,y); </li></ul></ul><ul><ul><li>Example in coding: </li></ul></ul><ul><li>#include <stdio.h> </li></ul><ul><li>#include <math.h> </li></ul><ul><li>int main (){ </li></ul><ul><li>double param, result; </li></ul><ul><li>param = 1024.0; </li></ul><ul><li>result = sqrt (param); </li></ul><ul><li>printf (&quot;sqrt(%lf) = %lfn&quot;, param, result ); </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul>
  4. 4. Trigonometric <ul><li>Sine </li></ul><ul><ul><li>Sin() </li></ul></ul><ul><ul><li>Example: result = sin (param*PI/180); </li></ul></ul><ul><li>Cosine </li></ul><ul><ul><li>cos() </li></ul></ul><ul><ul><li>Example : result = cos (param*PI/180); </li></ul></ul><ul><li>Tangent </li></ul><ul><ul><li>Tan() </li></ul></ul><ul><ul><li>Example: result = tan (param*PI/180); </li></ul></ul>
  5. 5. Sine exaple <ul><li>#include <stdio.h> </li></ul><ul><li>#include <math.h> </li></ul><ul><li>#define PI 3.14159265 </li></ul><ul><li>int main () </li></ul><ul><li>{ </li></ul><ul><li>double param, result; </li></ul><ul><li>param = 30.0; </li></ul><ul><li>result = sin (param*PI/180); </li></ul><ul><li>printf (&quot;The sine of %lf degrees is %lf.n&quot;, param, result ); </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul>
  6. 6. cosine <ul><li>#include <stdio.h> </li></ul><ul><li>#include <math.h> </li></ul><ul><li>#define PI 3.14159265 </li></ul><ul><li>int main () </li></ul><ul><li>{ </li></ul><ul><li>double param, result; </li></ul><ul><li>param = 60.0; </li></ul><ul><li>result = cos (param*PI/180); </li></ul><ul><li>printf (&quot;The cosine of %lf degrees is %lf.n&quot;, param, result ); </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul>
  7. 7. Tangent <ul><li>#include <stdio.h> </li></ul><ul><li>#include <math.h> </li></ul><ul><li>#define PI 3.14159265 </li></ul><ul><li>int main () </li></ul><ul><li>{ </li></ul><ul><li>double param, result; </li></ul><ul><li>param = 45.0; </li></ul><ul><li>result = tan (param*PI/180); </li></ul><ul><li>printf (&quot;The tangent of %lf degrees is %lf.n&quot;, param, result ); </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul>
  8. 8. Log <ul><li>Example : </li></ul><ul><li>#include <stdio.h> </li></ul><ul><li>#include <math.h> </li></ul><ul><li>int main (){ </li></ul><ul><li>double param, result; </li></ul><ul><li>param = 5.5; </li></ul><ul><li>result = log (param); </li></ul><ul><li>printf (&quot;ln(%lf) = %lfn&quot;, param, result ); </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul>
  9. 9. Exponential <ul><li>Example : </li></ul><ul><li>#include <stdio.h> </li></ul><ul><li>#include <math.h> </li></ul><ul><li>int main (){ </li></ul><ul><li>double param, result; </li></ul><ul><li>param = 5.0; </li></ul><ul><li>result = exp (param); </li></ul><ul><li>printf (&quot;The exponential value of %lf is %lf.n&quot;, param, result ); </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul>
  10. 10. Absolute value <ul><li>Example: </li></ul><ul><li>#include <stdio.h> </li></ul><ul><li>#include <math.h> </li></ul><ul><li>int main (){ </li></ul><ul><li>printf (&quot;The absolute value of 3.1416 is %lfn&quot;, fabs (3.1416) ); </li></ul><ul><li>printf (&quot;The absolute value of -10.6 is %lfn&quot;, fabs (-10.6) ); </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul>
  11. 11. <ul><li>QUESTION? </li></ul>
  12. 12. Log and exponential <ul><li>Example : </li></ul><ul><li>#include <stdio.h> </li></ul><ul><li>#include <math.h> </li></ul><ul><li>int main (){ </li></ul><ul><li>double param, result; </li></ul><ul><li>param = 5.5; </li></ul><ul><li>result = log (param); </li></ul><ul><li>printf (&quot;ln(%lf) = %lfn&quot;, param, result ); </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul>
  13. 13. Log and exponential <ul><li>Example : </li></ul><ul><li>#include <stdio.h> </li></ul><ul><li>#include <math.h> </li></ul><ul><li>int main (){ </li></ul><ul><li>double param, result; </li></ul><ul><li>param = 5.5; </li></ul><ul><li>result = log (param); </li></ul><ul><li>printf (&quot;ln(%lf) = %lfn&quot;, param, result ); </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul>

×