Thursday, November 22, 2012

C PROGRAM FOR EXPONENTIAL SERIES


                                    /* C PROGRAM FOR  EXPONENTIAL SERIES*/

#include<stdio.h>
#include<conio.h>
#include<math.h>
#define pi 3.14

void main()
{
       int n,i,j;
       float x,sum,p,f;
       clrscr();
       printf("\n\tEXPONENTIAL SERIES");
       printf("\n\t~~~~~~~~~~~~~~~~~~");
       printf("\n Enter the value of n:");
       scanf("%d",&n);
       printf("\n Enter the value for x:");
       scanf("%f",&x);
       x=x*(pi/180);
       sum=1;

for(i=1;i<=n;i++)
{
       p=1;
       f=1;

for(j=1;j<=i;j++)
{
       p=p*x;
       f=f*j;
}
       sum=sum+(p/f);
  }
       printf("\n The sum of series: %f",sum);
       printf("\n The cosine series: %f",exp(x));
getch();
}











OUTPUT:
        EXPONENTIAL SERIES
        ~~~~~~~~~~~~~~~~~~~~~~
 Enter the value of n: 4

 Enter the value for x: 6

 The sum of series: 1.110340
 The cosine series: 1.110340



0 comments:

Post a Comment