Q: write a program to receive cartesian coordinates and convert them in polar coordinate.
#include <stdio.h>
#include <math.h>
int main ()
{
float x,y,r,A;
printf("enter coordinate of point(x,y) :\n");
scanf("%f%f",&x,&y);
A = atan(y/x); /*formula used to find inverse*/
A = 180*A/3.14; /*formula used to convert radian to degree*/
r = sqrt(x*x + y*y); /*formula used to find dist of point from orgin*/
printf("polar cordinate for given point is (%f,%f)",r,A);
return 0;
}
-----------------------------------------
output :
enter coordinate of point(x,y) :
4
5
polar cordinate for given point is (6.403124,51.366234)
Comments
Post a Comment