Friday, 12 August 2016

How to use mathematical functions like sin,sqrt .

Remember the first line of our program ,it was
#include<stdio.h> ---actually this is a header file which contains some standard function definition(dont worry about the big word , just remember that you are able to use printf and scanf because of this)


So to use mathematical functions remember to write
#include<math.h>  


this contains function definition of mathematical functions.
Eg .   sqrt(x)  - for taking square root of a number.
         sin(x),cos(x) and other trignometric  functions.
         pow(x,y)-- to calculate values like x raised to power of y.
       
       
Imp: These all function will give a floating number as an output( the result will not be integer but it will a decimal number so use %f instead of %d).
eg    sqrt(25)=5.0  not 5.
   
 

 

No comments:

Post a Comment