// Online C compiler to run C program online #include <stdio.h> #include <math.h> struct tangle{ float x,y; }; struct polar{ float r, theta; }; struct polar convert(struct tangle rect){ struct polar pol; if(rect.x==0 && rect.y==0){ pol.r = pol.theta = 0; } else{ pol.r=sqrt(rect.x*rect.x + rect.y*rect.y); double ans = (rect.y,rect.x); pol.theta = atan(ans); } return pol; } int main() { struct tangle rect = {2,1}; struct polar p; p = convert(rect); printf("%.2f %.2f",p.r,p.theta); return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter