sin in c

What is sin in c programming?

sin in c is a mathematical function which is used to find sine of a given number.

This function is defined in math.h header file.

Prototype

#include<math.h>
double sin(double y);

Parameters

sin function takes floating point value as angle in radians.

Return value

This function returns sine of a given number.


Example program for sin in c

#include <stdio.h>
#include <math.h>
#define PI 3.14
int main() 
{
   double x, res, val1;
   x=25.0;
   val1=PI/180;
   res=sin(x*val1);
   printf("The sine of %lf is %lf degrees", x, res);
   return 0;
}
Example for sin in c programming

While using gcc use below command to add math header.

gcc file_name.c -lm

Code explanantion

The variable val1 is defined in terms of degrees. The number is passed to the sin function and it is multiplied by variable to get sine value in terms of degrees. The result is being printed onto the console.

Sin Man Page.


Difference between sin and sinh in c

sin in c is a mathematical function that is used to find the sine of a given number. sinh in c is used to find the hyperbolic sine of a given number.

Prototypes are as follows

double sin(double y);

double sinh(double y);
sin( )sinh( )
Used to find sine of a given number.Used to find hyperbolic sine of given number.
double sin(double y);double sinh(double y);

Difference between sin and cos in c

sin in c is a mathematical function that is used to find the sine of a given number. cos is a mathematical function that is used to find the cosine of a given number.

Prototypes are as follows

double sin(double y);

double cos(double y);
sin( )cos( )
Used to find sine of a given number.Used to find cosine of a given number.
double sin(double y);double cos(double y);

Difference between sin and tan in c

sin in c is a mathematical function that is used to find the sine of a given number. tan is a mathematical function that is used to find the tangent of a given number.

Prototypes are as follows

double sin(double y);

double tan(double y);
sin( )tan( )
Used to find sine of a given number.Used to find tangent of a given number.
double sin(double y);double tan(double y);

People also ask for

What is the sin equation?

It is a trigonometric function. The sin of an angle m is the length of the opposite side divided by the length of the hypotenuse.

What type of errors one can find if sin in c fails?

The errors are
1.Domain error
2.Range error.