In this tutorial, we will discuss Sine function in C programming Language
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.
The Declaration of the sin() function
double sin(double x);
the parameter of the sine function is:
x – This is the floating point value of an angle and always measured in radians(not degrees).
The sin() returns the sine of x, measured in radians.
In the C language, the required header of the sin() function in C
#include <math.h>
The following example shows the usage of sin() function
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
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…