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      

cosh function   in C  language                               

sinh function in C language

tanh function in C language

abs function in C language

floor function in C language

ceil function in C language

round function in C language

sqrt function in C language

pow function in C language

exp function in C language

log function in C language

log10 function in C language

trunc function in C language

 

 

suggested for you

Function in C language

User defined function in C language

Arithmetic functions in C Language

String function in C language

 

cos function in C programming language
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

Python code to Calculate sum of odd and even in a list

Python code to Calculate sum of odd and even in a list In this tutorial,…

53 minutes ago

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

3 days ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago