Answer to Question #274752 in C for sagun poudel

Question #274752

find the value of cosx by using the inbuilt function




1
Expert's answer
2021-12-03T08:21:49-0500
#include <stdio.h>
#include <cmath.h>

int factorial(int n) 
{
  return n == 1 ? 1 : n * factorial(n - 1);
}


double cos(double radian) 
{
  // using taylor's series
  return 1 - pow(radian, 2) / factorial(2) + pow(radian, 4) / factorial(4) - pow(radian, 4) / factorial(4);
}

int main() 
{ 
  printf("%.6f", cos(PI));
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS