C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 2
Q: (d) Write a program to receive Cartesian co-ordinates (x, y) of a point and convert them into polar co-ordinates (r, ). Hint: r = sqrt ( x2 + y2 ) and 𝝫 = tan-1 ( y / x )
#include <stdio.h>
#include<math.h>
int main()
{
double x,y,r,p;
printf("Enter Cartesian Co-ordinates x,y :\n");
scanf("%lf%lf", &x,&y);
r=sqrt(x*x+y*y);
p=atan(y/x);
printf("Polar Co-ordinates are ( %lf , %lf )",r,p);
return 0;
}
No comments:
Post a Comment