Q: write a program to receive cartesian coordinates and convert them in polar coordinate.


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

int main ()
{
    float x,y,r,A;
   
               printf("enter coordinate of point(x,y) :\n");
    scanf("%f%f",&x,&y);
   
    A = atan(y/x);    /*formula used to find inverse*/
    A = 180*A/3.14;    /*formula used to convert radian to degree*/
    r = sqrt(x*x + y*y);    /*formula used to find dist of point from orgin*/
   
    printf("polar cordinate for given point is (%f,%f)",r,A);
    return 0;
}
-----------------------------------------
output :

enter coordinate of point(x,y) :
4
5
polar cordinate for given point is (6.403124,51.366234)

Comments

Popular posts from this blog

Q: The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate area & perimeter of the rectangle and area & circumference of the circle.

Q: If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator ‘%’)