norm() function in C++ with Examples Last Updated : 14 Mar, 2023 Comments Improve Suggest changes Like Article Like Report The norm() function is defined in the complex header file. This function is used to return the squared magnitude of the complex number z. Syntax: template<class T> T norm (const complex<T>& z); Parameter: z: It represents the given complex number. Return: It returns the squared magnitude of the complex number. Time Complexity: O(1) Auxiliary Space: O(1) Below programs illustrate the above function:- Example 1:- CPP // C++ program to demonstrate // example of norm() function. #include <bits/stdc++.h> using namespace std; // driver function int main () { // initializing the complex: (5.0+12.0i) complex<double> complexnumber (5.0, 12.0); // use of norm()function cout << "The norm of " << complexnumber << " is "; cout << norm(complexnumber) << endl; return 0; } Output:The norm of (5,12) is 169 Example 2:- CPP // C++ program to demonstrate // example of norm() function. #include <bits/stdc++.h> using namespace std; // driver function int main () { // initializing the complex: (4.0+3.0i) complex<double> complexnumber (4.0, 3.0); // use of norm()function cout << "The norm of " << complexnumber << " is "; cout << norm(complexnumber) << endl; return 0; } Output:The norm of (4,3) is 25 Comment More infoAdvertise with us Next Article norm() function in C++ with Examples B bansal_rtk_ Follow Improve Article Tags : Misc C++ CPP-Library cpp-numerics-library Practice Tags : CPPMisc Similar Reads log2() function in C++ with Examples The function log2() of cmath header file in C++ is used to find the logarithmic value with base 2 of the passed argument. Syntax: log2(x) Parameters: This function takes a value x, in the range [0, ∞] whose log value is to be found. Return Type: It returns the logarithmic value, as double, flo 2 min read ios good() function in C++ with Examples The good() method of ios class in C++ is used to check if the stream is good enough to work. It means that this function will check if this stream has raised any error or not. Syntax: bool good() const; Parameters: This method does not accept any parameter. Return Value: This method returns true if 1 min read ios operator() function in C++ with Examples The operator() method of ios class in C++ is used to any error flag of this stream is set. This includes the failbit or the badbit. Syntax: operator void*() const; Parameters: This method does not accept any parameter. Return Value: This method returns a null pointer if any error bit is set of this 1 min read ios operator !() function in C++ with Examples The operator!() method of ios class in C++ is used to any error flag of this stream is set. This includes the failbit or the badbit. Syntax: bool operator!() const; Parameters: This method does not accept any parameter. Return Value: This method returns true if any error bit is set of this stream, e 1 min read fill() function in C++ STL with examples The fill() function in C++ STL is used to fill some default value in a container. The fill() function can also be used to fill values in a range in the container. It accepts two iterators begin and end and fills a value in the container starting from position pointed by begin and just before the pos 2 min read Like