Pages

Write a program which takes input in Cartesian coordinates (x, y) and calculate and display the Polar coordinates.

Wednesday, 12 March 2014

Write a program which takes input in Cartesian coordinates (x, y) and calculate and display the Polar  coordinates.

#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    float r, thet = 0, rad, x, y;
    cout << "Enter value of x-axis: ";
    cin>>x;
    cout << "Enter value of y-axis: ";
    cin>>y;
    r = (x*x) + (y*y);
    r = sqrt(r);
    thet = atan2(x,y) * 180 / 3.1415;
    cout << endl << "Coordinates in Polar is (" << r << " , " << thet << ")" << endl;
    system("pause");
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *