Tuesday, 24 February 2015

Sine() series Program in C++

#include<iostream.h>
#include<conio.h>
#include<math.h>
long fact(long);
main()
{
long base,power,i,j;
float res=1.0;
clrscr();
cout<<"\n Enter Base Value\n";
cin>>base;
cout<<"\n Enter Power Value\n";
cin>>power;

for(i=1;i<=power;i++)
{
res+=pow(base,i)/fact(i+1);
}
cout<<"\n Result is "<<res;
getch();
}
long fact(long fact)
{
long b=fact;
if(b==0)
return 1;
else
for(long i=1;i<fact;i++)
{
b=b*i;
}
return b;
}

No comments:

Post a Comment