Wednesday, 8 February 2012

print below give sum of the series.

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
 { 
                    // x+x^2/2!+x^3/3!+...... 
                   int  x,n,i,p,f;
                   float s=0;
                   f=1;
                   printf("enter the no\n");
                   scanf("%d",&n);
                   printf("enter the no\n");
                   scanf("%d",&x);
                    for(i=1;i<=n;i++)
                    {
                         f=f*i;
                         p=pow(x,i);
                         s=s+(p/f);
                     }
                        printf("%f",s);
                    getch();
 }

o/p:-
enter the no
10
enter the no
 0
 o.oooooo












No comments:

Post a Comment