- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
norm() function in C++ with Examples
In this article we will be discussing the working, syntax and examples of norm() function in C++ STL.
What is norm()?
norm() function is an inbuilt function in C++ STL, which is defined in <complex> header file. norm() function is used to get the norm value of a complex number.
Norm value of a complex number is the squared magnitude of a number. So in simple words the function finds the squared magnitude of a complex number, including its imaginary and real number.
Syntax
double norm(ArithmeticType num);
Parameters
The function accepts following parameter(s) −
- num − The complex value which we want to work on.
Return value
This function returns a norm value of num.
Example
Input
complex<double> comp_num(6.9, 2.6); norm(comp_num);
Output
The value of norm of (6.9,2.6) is 54.37
Example
#include <bits/stdc++.h> using namespace std; int main (){ complex<double> comp_num(6.9, 2.6); cout<<"The value of norm of " << comp_num<< " is "; cout << norm(comp_num) << endl; return 0; }
Output
The value of norm of (6.9,2.6) is 54.37
Example
#include <bits/stdc++.h> using namespace std; int main (){ complex<double> comp_num(2.4, 1.9); cout<<"The value of norm of " << comp_num<< " is "; cout << norm(comp_num) << endl; return 0; }
Example
The value of norm of (2.4,1.9) is 9.37
Advertisements