Sine function in C programming Language
- Home
- function in C
- Sine function in C programming Language
- On
- By
- 0 Comment
- Categories: function in C, Library function in C, pre-define maths function in C
Sine function in C programming Language
Sine function in C programming Language
In this tutorial, we will discuss Sine function in C programming Language
Sine function in C
Description
Description of the C programming Language Sin() function
In C programming language the sine function returns the sine of the radian angle x.
sin(): In the C programming Language this is used to calculate sine value to given radians.
Declaration
The Declaration of the sin() function
double sin(double x);
Parameter or Arguments
the parameter of the sine function is:
x – This is the floating point value of an angle and always measured in radians(not degrees).
Returns
The sin() returns the sine of x, measured in radians.
Required header
In the C language, the required header of the sin() function in C
#include <math.h>
Example – Sin() in C programming
The following example shows the usage of sin() function
Program for Sine function in C
Program 1
#include <stdio.h> #include <math.h> int main() { double x=0.5,y=1;//define and initiates variables printf("sine value of %f is %f\n",x,sin(x)); printf("sine value of %f is %f\n",y,sin(y)); getch(); return 0; }
When compile and run above program, this will produce the following result
sine value of 0.500000 is: 0.479426 sine value of 1.000000 is: 0.841471
Program 2
#include <stdio.h> #include <math.h> //sin calculator in C int main() { //define variables float sineValue,inputValue; //Get input from user printf("please enter the value to calculate sine: "); scanf("%f",&inputValue); //Calculate the sine value sineValue=sin(inputValue); //Display the sine value printf("\nThe sine value of %f is =%f",inputValue,sineValue); getch(); return 0; }
When compile and run above program, this will produce the following result
please enter the value to calculate sine: 2.56
The sine value of 2.560000 is =0.549356
Similar Functions
Other C programming language functions that are similar to the cosine function
suggested for you
User defined function in C language
Arithmetic functions in C Language