Welcome Guest ( Log In | Register )

Bump Topic Topic Closed RSS Feed

Outline · [ Standard ] · Linear+

 yeah.i'm stuck, c++ need help@guide

views
     
TSdirtinacan
post Jan 25 2006, 10:07 PM, updated 20y ago

Casual
***
Junior Member
381 posts

Joined: Jan 2003


hi all.so,this is my asgmt.need to use the binomial theorem.

http://en.wikipedia.org/wiki/Binomial_theorem
here a link about the theorem

but i only need to the the (a+b)^n
where a=1 and n is a integer and 0<b<1

here's my code.can't seem to execute properly.no programming error.i think so la


posted at edu essential.but i don't think they can help cry.gif whistling.gif tongue.gif

#include <stdio.h>
#include <math.h>


double facto (double fac);
double kire_2(int a,double b,int n);

double kire_2(int a,double b,int n)
{
double sum1=0,sum2=0,count=0,temp_m=1,temp_n;
for(temp_n=1;count>=0;count++)
{
sum1+=temp_m*pow(a,n-count)*pow(b,count);
temp_m*=(n-count)/facto(count+1);

if(n-count==count)
return sum1+sum2;

sum2+=temp_n*pow(a,count)*pow(b,n-count);
temp_n*(n-count)/facto(count+1);
}
}

double facto (double fac)
{
double bogey;
if(fac==0)
return 1;
for(bogey=1;fac>=2;fac--)
bogey*=fac;
return bogey;
}

int main()
{
int n,a=1;
double b;
printf("Enter b and n\n");
scanf("%lf %d",&b,&n);
printf("(%d+%.2lf)^%d",kire_2(a,b,n));
scanf("lf",&n);

return 0;
}

the error:entered b and n but the program just exit and didn't show anything
me:using bloodshed c++

hope u all can help me thumbup.gif
TSdirtinacan
post Jan 27 2006, 11:39 AM

Casual
***
Junior Member
381 posts

Joined: Jan 2003


view the other topic.huhu

Topic ClosedOptions
 

Change to:
| Lo-Fi Version
0.0138sec    0.35    5 queries    GZIP Disabled
Time is now: 23rd December 2025 - 04:32 AM