[C] language polar coordinates into Cartesian coordinates

Write a program to polar coordinates (r, θ) (θ of degrees) is converted into rectangular coordinates (X, Y).
Conversion formula is X = r.cosθ  Y = r.sinθ

Program output; outputting the converted coordinates.

Code:

#include <stdio.h>
#include <math.h>
#define PI 3.1415926

int main ()
{
    float r, angle, x, y;
    the printf ( " Please enter the polar coordinates (r, θ) r and the [theta] \ n- " );
    scanf_s("%f %f", &r, &angle);
    x = r * cos(angle * PI / 180);
    and = r * sin (angle * PI / 180 );
    the printf ( " Rectangular Coordinates (% F,% F) \ n- " , X, Y);
     return  0 ;
}

 

Guess you like

Origin www.cnblogs.com/HGNET/p/11885456.html