function in C

tan function in C programming language

tan function in C programming language

In this tutorial we will discuss about tan function in C programming language

Description

Description of tan()  in C programming language

The tan() in C programming  language  returns the tangent of the radian angle x

tan() : In the C programming Language, the tan() function is used to calculate tangent value of the given value .

Declaration

The declaration of the tan() C programming language is

double tan(double x);

Parameters or Arguments

parameter of tan  is:

x  – it is a floating point value assigned to the angle as the parameter of this function and always measured in radians.

Returns

The tan function returns tangent value  of x, measured in radians

 

Required header

The required header of the tan() function is

#include <math.h>

tan function in C

Example

Following example shows the usage of the tangent function

Program 1

 

#include <stdio.h>
#include <stdlib.h>

int main()
{
    double x=0.5,y=1;

    printf("Tangent value of %f is:%f\n",x,tan(x));
    printf("Tangent value of %f is:%f\n",y,tan(y));
    return 0;
}

 

When above program compiled and run, it will produce the following results.

tangent value of 0.500000 is: 0.546302
tangent value of 1.000000 is: 1.557408

Program 2

#include <stdio.h>
#include <math.h>

int main()
{   //define the variable
    double tangentValue;
    double inputValue;
    //get input from user
    printf("Please enter the value to calculate tangent value :");
    scanf("%lf",&inputValue);
    //calculate the tangent value
    tangentValue=tan(inputValue);
    //display the tangent value
     printf("\ntangent value of %lf is %lf\n",inputValue,tangentValue);
    getch();
    return 0;
}

When above program compiled and run, it will produce the following results.

Please enter the value to calculate tangent value :0.5
tangent value of 0.800000 is 0.546302

 

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

 

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
tanh 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

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

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

1 month ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

1 month ago