/*gowrikausalya.blogspot.com*/
/*c-program to convert polar form to rectangular form*/
#include<stdio.h>
#include<math.h>/*to use sqrt,atan(tan inverse),cos,sin,etc*/
#include<conio.h>
#define pi 3.1415927/*use preprocessor to set value for pi as 3.14..*/
int main()
{
double rp,ip,mag,ang;
printf("enter the magnitude :\t");
scanf("%lf",&mag);
printf("\nenter the angle : \t");
scanf("%lf",ang);
rp= (mag * (cos ( (ang * pi) / 180) ) );
ip= (mag * (sin ( (ang * pi) / 180) ) );
printf("\n\n Real part is %.3lf",rp);
printf("\nImaginery part is %.3lf",ip);
getch();
}
output:-
enter the magnitude : 12
enter the angle : 90
Real part is 12.000
Imaginery part is 0.000
No comments:
Post a Comment