C Program to Convert Cartesian Coordinates to Polar Coordinate

#include<stdio.h>
#include<conio.h>
#include<math.h>

#define PI 3.141592

int main()
{
float x, y, r, theta;
clrscr();
printf(“Enter cartesian coordinate x: “);
scanf(“%f”, &x);
printf(“Enter cartesian coordinate y: “);
scanf(“%f”, &y);

/* Calculating r */
r = sqrt(x*x + y*y);

/* Calculating theta in radian */
theta = atan(y/x);

/* Converting theta from degree to radian */
theta = 180.0 * theta/ PI;

printf(“Polar coordinate is: r = %0.2f and theta = %0.2f in degree”, r, theta);
getch(); /* Holds Screen */

return(0);
}

Output

 

Enter cartesian coordinate x: 1 ↲
Enter cartesian coordinate y: 1 ↲
Polar coordinate is: r = 1.41 and theta = 45.00 in degree

Leave a Reply

Your email address will not be published. Required fields are marked *

https://atozonlinesolutions.com/wp-content/uploads/2017/03/logo_white.png
https://atozonlinesolutions.com/wp-content/uploads/2017/03/logo_white.png
About
Products
Subscribe

If you wish to receive our latest news in your email box, just subscribe to our newsletter. We won’t spam you, we promise!

    Applauz

    As the pioneer of the lean startup movement, APPLAUZ has dedicated it’s time to sharing effective business strategies that help new businesses and enterpreneurs put their money to work in the right way.

    Subscribe

    If you wish to receive our latest news in your email box, just subscribe to our newsletter. We won’t spam you, we promise!

      Applauz

      As the pioneer of the lean startup movement, APPLAUZ has dedicated it’s time to sharing effective business strategies that help new businesses and enterpreneurs put their money to work in the right way.

      Copyright by BOLD THEMES. All rights reserved.