#include<stdio.h>>
#include<conio.h>
#include<math.h>
int main()
{
float x, y, r, theta;
printf("Enter the x and y coordinates : ");
scanf("%f%f", &x, &y);
r = sqrt(x*x + y*y);
theta = atan(y/x);
//atan() is a function to find the tan inverse
printf("\nCoordinates in polar form : %.2f(cos(%.2f) + i.sin(%.2f))", r, theta, theta);
//%.2f means only two decimal palces will be printed.
getch();
return 0;
}
Ad
Chapter - 2: C Instructions
Write a program to receive cartesian coordinates (x,y) of a point and convert them into polar coordinates. (r,theta)
Ad
Ad