
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
polar() function for complex number in C++
The polar function of complex numbers is used to return a complex number.
The polar() function is defined in the complex header file in c++. It takes the magnitude and phase angle of a complex number and generates a complex number using these values.
Syntax
polar(mag, phase);
Parameters − it takes two values are parameters, the phase, and magnitude of the complex number to be generated.
Return value − the function returns a complex number.
polar(0.2, 0.5) -> (0.175517,0.0958851)
Example
#include<iostream> #include>complex.h> using namespace std; int main () { cout<<"\t\tRUN 1\n"; cout<<"Complex number with magnitude: 5.2 and phase angle: 1.6 is "; cout<<polar(5.2,1.6)<<endl; cout<<"\t\tRUN 2\n"; cout<<"Complex number with magnitude: 0.5 and phase angle: 0.2 is "; cout<<polar(0.5,0.2)<<endl; cout<<"\t\tRUN 3\n"; cout<<"Complex number with magnitude: 0.2 and phase angle: 0.5 is "; cout<<polar(0.2,0.5)<<endl; return 0; }
Output
RUN 1 Complex number with magnitude: 5.2 and phase angle: 1.6 is (-0.151838,5.19778) RUN 2 Complex number with magnitude: 0.5 and phase angle: 0.2 is (0.490033,0.0993347) RUN 3 Complex number with magnitude: 0.2 and phase angle: 0.5 is (0.175517,0.0958851)
- Related Articles
- arg() function for Complex Number in C++
- abs() function for complex number in c++ ?
- acosh() function for complex number in C++
- acos() function for complex number in C++?
- asin() function for complex number in C++?
- atan() function for complex number in C++?
- tanh( ) function for complex Number in C++
- log() function for complex number in C++
- log10() function for complex number in C++
- tan() function for complex number in C++
- Cos() function for complex number in C++
- pow() function for complex number in C++
- exp() function for complex number in C++
- sqrt ( ) function for complex number in C++
- Sinh( ) function for complex number in C++

Advertisements