2. Danger zone 1
atan()
In C programming atan() function computes the arc tangent(inverse tangent) of an argument.
Function atan() takes single argument and returns the value in radians.
Returned value of atan is of type double.
o Header File : Math.h
o Syntax : double atan(argument);
*EXAMPLE*
#include <stdio.h>
#include <math.h>
#define PI 3.141592654
void main()
{
float num;
double result;
printf("Enter the parameter: ");
scanf("%f",&num);
result=atan(num);
printf("Inverse of tan(%.2f)=%.2f in
radians",num,result);
/* ------ Converting radians to degree -------- */
result=(result*180)/PI;
printf("nInverse of tan(%.2f)=%.2f in
degrees",num,result);
}
3. Danger zone 2
Output :
Enter the parameter: 1
Inverse of cos(1.00)=0.79 in radians
Inverse of cos(1.00)=45 in degrees
4. Danger zone 3
In C programming, cos() function computes the cosine of an argument.
Function cos() takes the value in radian and returns value in type double.
o Header file : Math.h
o Syntax :double cos(argument);
*Example*
#include <stdio.h>
#include <math.h>
#define PI 3.141592654
void main()
{
double arg,result;
printf("Enter the argument in degrees: ");
scanf("%lf",&arg);
/*------ Converting to radian --------*/
arg=(arg*PI)/180;
result=cos(arg);
printf("cos of %.2lf radian = %.2lf",arg, result);
}
6. Danger zone 4
Div() Integer Division
In the C Programming Language, the div function divides numerator by denominator.
Based on that division calculation, the div function returns a structure containing two
members - quotient and remainder.
o Header file : #include <stdlib.h>
o Syntax : div_t div(int numerator, int denominator);
Parameters or Arguments
Numerator:The value that is divided by denominator in the division calculation.
Denominator:The value divided into numerator in the division calculation. So if
numerator is 10 and denominator is 2, then 10 would be divided by 2.
Returns
The div function returns a structure with the resulting quotient and remainder based on
the division calculation.
7. Danger zone 5
*Example*
#include <stdio.h>
#include <stdlib.h>
void main ()
{
div_t output;
output = div(27, 4);
printf("Quotient part of (27/ 4) = %dn", output.quot);
printf("Remainder part of (27/4) = %dn", output.rem);
output = div(27, 3);
printf("Quotient part of (27/ 3) = %dn", output.quot);
printf("Remainder part of (27/3) = %dn", output.rem);
getch();
}
8. Danger zone 2
Output :
Quotient part of (27/4) = 6
Remainder part of (27/4) =3
Quotient part of (27/3) = 9
Remainder part of (27/3) = 0
9. • In C programming, sin() function computes the sine of an argument. Function
sin() takes the value in radian and returns value in type double.
Header file : Math.h
Syntax : double sin (argument);
*Example*
#include <stdio.h>
#include <math.h>
#define PI 3.141592654
void main()
{ double arg,result;
printf("Enter the argument in degrees: ");
scanf("%lf",&arg);
/*------ Converting to radians --------*/
arg=(arg*PI)/180; result=sin(arg);
printf("sin(%.2lf) [In radian] = %.2lf",arg, result);
}
Sin()
10. Danger zone 2
Output :
Enter the argument in degrees:
30cos(0.52) [In radian] = 0.50