C Program to Convert Polar Coordinate to Cartesian Coordinates

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

#define PI 3.141592

int main()
{
	 float x, y, r, theta;
	 clrscr();
	 printf("Enter radius of polar coordinate (r): ");
	 scanf("%f", &r);
	 printf("Enter angle of polar coordinate in degree (theta): ");
	 scanf("%f", &theta);
	
	 /* Converting theta from degree to radian */
	 theta = theta * PI/180.0;
	
	 /* Calculating cartesian coordinate x */
	 x = r * cos(theta);
	
	 /* Calculating cartesian coordinate y */
	 y = r * sin(theta);
	
	 printf("Cartesian coordinates is: (%0.3f, %0.3f)", x, y);
	 getch();
	 return(0);
}

Output

Enter radius of polar coordinate (r): 1.4142 ↲
Enter angle of polar coordinate in degree (theta): 45 ↲
Cartesian coordinates is: (1.000, 1.000)

   

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.