===========================================================================
CODING
#include<all.h>
void main()
{
long n,i,q,z,p,m,r,j,k,b,h,v,a;
clrscr();
gotoxy(1,3);
cprintf("(a+b)^");
cin>>n;
gotoxy(9,3);
for(i=0;i<=n;i++)
{
for(q=1,m=1;q<=n;q++)
m=q*m;
for(z=1,r=1;z<=i;z++)
r=z*r;
for(p=1,j=1;p<=(n-i);p++)
j=p*j;
if(i==0)
cout<<" = "<<m/(r*(j))<<"*(a^"<<n-i<<"*b^"<<i<<")";
else if(i<=n)
cout<<" + "<<(double)m/(r*(j))<<"*(a^"<<n-i<<"*b^"<<i<<")";
}
cout<<"\n\n";
b=n;
for(i=0;i<=n;i++)
{
for(a=1;a<=b;a++)
cout<<" ";
if(i==0)
{
cout<<"\b\b\bVERIFY:-\n";
for(a=1;a<=b;a++)
cout<<" ";
cout<<"\b\b\b------\n";
for(a=1;a<=b;a++)
cout<<" ";
cout<<"1";
}
else
{
for(h=0;h<=i;h++)
{
for(q=1,m=1;q<=i;q++)
m=q*m;
for(z=1,r=1;z<=h;z++)
r=z*r;
for(p=1,j=1;p<=i-h;p++)
j=p*j;
if(m/(r*j)>=0 && m/(r*j)<10)
cout<<m/(r*(j))<<" ";
else if(m/(r*j)>=10 && m/(r*j)<100)
cout<<"\b"<<m/(r*(j))<<" ";
else
cout<<"\b\b"<<m/(r*(j))<<" ";
}
}
b=b-1;
cout<<"\n";
}
getch();
}
CODING
#include<all.h>
void main()
{
long n,i,q,z,p,m,r,j,k,b,h,v,a;
clrscr();
gotoxy(1,3);
cprintf("(a+b)^");
cin>>n;
gotoxy(9,3);
for(i=0;i<=n;i++)
{
for(q=1,m=1;q<=n;q++)
m=q*m;
for(z=1,r=1;z<=i;z++)
r=z*r;
for(p=1,j=1;p<=(n-i);p++)
j=p*j;
if(i==0)
cout<<" = "<<m/(r*(j))<<"*(a^"<<n-i<<"*b^"<<i<<")";
else if(i<=n)
cout<<" + "<<(double)m/(r*(j))<<"*(a^"<<n-i<<"*b^"<<i<<")";
}
cout<<"\n\n";
b=n;
for(i=0;i<=n;i++)
{
for(a=1;a<=b;a++)
cout<<" ";
if(i==0)
{
cout<<"\b\b\bVERIFY:-\n";
for(a=1;a<=b;a++)
cout<<" ";
cout<<"\b\b\b------\n";
for(a=1;a<=b;a++)
cout<<" ";
cout<<"1";
}
else
{
for(h=0;h<=i;h++)
{
for(q=1,m=1;q<=i;q++)
m=q*m;
for(z=1,r=1;z<=h;z++)
r=z*r;
for(p=1,j=1;p<=i-h;p++)
j=p*j;
if(m/(r*j)>=0 && m/(r*j)<10)
cout<<m/(r*(j))<<" ";
else if(m/(r*j)>=10 && m/(r*j)<100)
cout<<"\b"<<m/(r*(j))<<" ";
else
cout<<"\b\b"<<m/(r*(j))<<" ";
}
}
b=b-1;
cout<<"\n";
}
getch();
}
===========================================================================
No comments:
Post a Comment