Program to convert polar co | C ++ program for the above approach ; Function to convert degree to radian ; Function to convert the polar coordinate to cartesian ; Convert degerees to radian ; Applying the formula : x = rcos ( theata ) , y = rsin ( theta ) ; Print cartesian coordinates ; Driver Code ; Given polar coordinates ; Function to convert polar coordinates to equivalent cartesian coordinates
#include <bits/stdc++.h> NEW_LINE using namespace std ; double ConvertDegToRad ( double degree ) { double pi = 3.14159 ; return ( degree * ( pi / 180.0 ) ) ; } void ConvertToCartesian ( pair < double , double > polar ) { polar . second = ConvertDegToRad ( polar . second ) ; pair < double , double > cartesian = { polar . first * cos ( polar . second ) , polar . first * sin ( polar . second ) } ; printf ( " % 0.3f , ▁ % 0.3f " , cartesian . first , cartesian . second ) ; } int main ( ) { pair < double , double > polar = { 1.4142 , 45 } ; ConvertToCartesian ( polar ) ; return 0 ; }