arg() function for Complex Number in C++

C++Server Side ProgrammingProgramming

C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

Master C and Embedded C Programming- Learn as you go

Best Seller

66 Lectures 5.5 hours

A complex number is a number that is expressed in the form of a + bi, where a and b are real numbers. i is the imaginary part of number.

The argument is the angle between the positive axis and the vector of the complex number. For a complex number

z = x + iy denoted by arg(z),

For finding the argument of a complex number there is a function named arg() of a complex number in the complex header file.

Syntax

arg(complex_number);

Parameter

The function accepts a complex number as input to calculate the value of the argument for that complex number.

Returned value

The function returns the argument of the complex number.

Example

Live Demo

#include<iostream>
#include<complex.h>
using namespace std;
int main (){
double a = 12.0, b = 56.0;
complex<double> complexnumber (a, b);
cout<<"The argument of complex number "<<a<<" + i"<<b<< " is: ";
cout<<arg(complexnumber)<<endl;
return 0;
}

Output

The argument of complex number 12 + i56 is: 1.3597

Updated on 24-Oct-2019 08:48:28