title: Why am I not getting accurate value of cosx?
body: <pre><code>#include&lt;iostream&gt;
  #include&lt;conio.h&gt;
  using namespace std;
  
  #define pi 3.1415
  
  int main(){
      system(&quot;cls&quot;);
      float x;
      int n;
      cout&lt;&lt;&quot;Enter the value of x(degree) : &quot;;
      cin&gt;&gt;x;
      cout&lt;&lt;&quot;Enter the value of n : &quot;;
      cin&gt;&gt;n;
      cout&lt;&lt;&quot;The value of Cos(&quot;&lt;&lt;x&lt;&lt;&quot;) is : &quot;;
      x = x*pi/180;
      float temp = 1, cos=1;
      for(int i=0; i&lt;=n; i++){
          temp *= (-1)*(x*x)/((i+2)*(i+1));
          cos += temp;
      }
      cout&lt;&lt;cos;
      getch();
      system(&quot;cls&quot;);
  }
  </code></pre>
  <p>I have tried a bigger value of pi too, but still am getting quite inaccurate value at second decimal point.</p>