Quote:
Originally Posted by virxen
check the result again.i think it must be 2.7083
i made 2 corrections and also i changed how scanf gets its data.
Code:
#include<stdio.h>
#include<conio.h>
float expo(float,float,int,float);
float term(float,float,float);
int main()
{
int n;
float e=0.0,t=1.0,x;
static float s=1.0;
//clrscr();
printf("\nenter variable:");
scanf("%f",&x);
printf("\nenter no of terms:");
scanf("%d",&n);
e=expo(x,t,n,s);
printf("\nsum=%f",e);
getch();
return 0;
}
float expo(float x,float t,int n,float s){
float c=1.0,e=0;
if(t<n){
e=term(x,t,c);
s=s+e;
t++;
s=expo(x,t,n,s);
}
return(s);
}
float term(float x,float t,float c)
{
if(t>=1){
c=c*(x/t);
c=term(x,t-1,c);
}
return(c);
}
thanks virxen, i m very happy to get sol.,pls tell me whats the actual problem in prog at (
vipul.fifteen@yahoo.com)
once again thanks