﻿

# atan2() function of math.h in C

﻿

In this article, we are going to learn about the use atan2() function of math.h header file in C language and use it with the help of an example.
Submitted by Manu Jemini, on April 03, 2018

This function provides the functionality to calculate the arc tangent in radians of ratio of coordinate Y by coordinate X . The value should be less than equal to π and greater than equal to –π.

This function takes two parameters as the X, Y coordinates, whose arc tangent value needs to be calculated and return the value which is the result of the calculation.

Example:

X = 0.7 and Y = 0.5
The function will return 0.950547

This function is a part of math.h library and it must be included in the program.

﻿

## math.h - atan2() function Example in C

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

int main()
{
// Defining variables
double a,b,c;

// Assigning value for getting atan2 value
a = 0.7;
b = 0.5;

// Calculating the arc tangent for both x any y axis.
c = atan2(a,b);

// Displaying the result for user
printf("The calculated value is: %lf \n\n", c);

return 0;
}

Output

﻿

﻿

﻿
﻿

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com (2015-2018), Some rights reserved.