# UVa 12575 – Sin Cos Problem

This one is a very interesting problem :).
In this problem I used atan2(a,b) library function, which returns the tan inverse value for all four quadrant on the other hand atan(a/b) returns the tan inverse value for 1st and 4th quadrant.

```/*
User id: turing_13
*/

#include &lt;iostream&gt;
#include &lt;cstdio&gt;
#include &lt;cmath&gt;
#define PI acos(-1)
using namespace std;

int main()
{
int t;
double a,b;
cin&gt;&gt;t;
while(t--)
{
cin&gt;&gt;a&gt;&gt;b;
double angle=atan2(a,b);
if(angle&lt;0)
angle+=(2*PI);
printf(&quot;%.2lf %.2lf\n&quot;,angle,sqrt(a*a+b*b));
}
return 0;
}

```

And another solution is here…

```
#include &lt;iostream&gt;
#include &lt;cstdio&gt;
#include &lt;cmath&gt;
#define PI acos(-1)
using namespace std;

int main()
{
int t;
double a,b;
cin&gt;&gt;t;
while(t--)
{
cin&gt;&gt;a&gt;&gt;b;
if(a==0 &amp;&amp; b==0)
{
cout&lt;&lt;&quot;0.00 0.00\n&quot;;
continue;
}
double angle=atan(a/b);
double ans=sqrt(a*a+b*b);
for(; angle&lt;=2*PI; angle+=(PI/2))
if(abs(a*sin(angle)+b*cos(angle)-ans)&lt; 0.01 &amp;&amp; angle&gt;=0)
break;
printf(&quot;%.2lf %.2lf\n&quot;,angle,ans);
}
return 0;
}

```