Make a new start with a new Thought!

NOTE :                // indicates comments.This wont get printed in the output.This is used for for documentation purpose. PROGRAM: #incl...

Cosine series expansion

NOTE :
              
// indicates comments.This wont get printed in the output.This is used for for documentation purpose.

PROGRAM:

#include<stdio.h>
#include<conio.h>
void main()
{
  float x,term,sum;
  int i,n;
  clrscr();
  printf("\nEnter the value of n\t:\t");
  scanf("%d",&n);
  printf("Enter the value of x in degrees\t:\t");
  scanf("%f",&x);
  x=(x*3.14)/180;
  sum=1;
  term=1;
  for(i=1;i<=n;i++)
  {
     term=(term*(-1)*x*x)/((2*i)*(2*i-1));
     sum=sum+term;
  }
  printf("Cos value of given angle is %f",sum);
  getch();
}

OUTPUT :


0 comments: