bsc

Comprehensive codebase and coursework for the 4-year B.Sc. Computer Science Honours degree (WBSU)

git clone https://github.com/notamitgamer/bsc.git
· rebuilt hourlyOpen on GitHub
root / semester_1 / letusc / luc005.c

luc005.c (544B)


      1 /* Write a program to recive Cartesian
      2 co-ordinates (x, y) of a point and convert
      3 them into Polar co-ordinates (r, phi)
      4     Hint : r = sqrt (x^2 + y^2) and phi = tan^-1 (y/x) */
      5 /* Let Us C; Page - 37; Chap- 2; QNo.: G(b) */
      6 
      7 #include <stdio.h>
      8 #include <math.h>
      9 int main()
     10 {
     11     double x, y, r, phi;
     12     printf("Enter the Cartesian Co-Ordinates in this format 'x, y' : ");
     13     scanf("%lf, %lf", &x, &y);
     14     r = sqrt(pow(x, 2) + pow(y, 2));
     15     phi = atan2(y, x);
     16     printf("\nPolar Co-Ordinates are : (%g, %g Rad)", r, phi);
     17     return 0;
     18 }