Find modulus of complex number in C by R4R Team

Complex number:

Example :
2+3i
0+4i
-1-9i
These kind of number are known as complex number.
where 'i' is root -1.

Syntax-
a+bi

where,
'a' is the real part of the complex number
'b' is the imaginary part of the complex number.

Modulus of complex number:
x=3+4i
then modulus=5


program-

#include< stdio.h>
#include< math.h>
int main() {
int r,i;
float mod;
printf("Enter real and imaginary part of complex number\n");
scanf("%d%d",&r,&i);
mod=pow(r*r+i*i,0.5);
printf("Modulus is: %f",mod);
}


output-

Enter real and imaginary part of complex number
3
4
Modulus is: 5.000000




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!