<!-- /* Font Definitions */ @font-face {font-family:"Agency FB"; mso-font-alt:"Trebuchet MS";} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; font-size:14.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt;} div.Section1 {page:Section1;} -->
مثال27 ) برنامه ای بنویسید که حاصل عبارت زیر را محاسبه کند.
n 2 n1
C = n1 / n1 - n2 /n2
# include <stdio.h>
# include <conio.h>
Int power(inta,intb )
{
Int I,p;
P=1;
For (i=1;i<=n;i++);
P=p*a;
Return p;
}
Int main( )
{
Int n1,n2;
Float n3,x,y ;
Scanf("%d %d \n ", &n1,&n2);
X=poer(n1,n2)/n1;
Y=power(n2,n1)/n2;
N3=x-y;
Printf("%f ", n3);
Return(0);
}
مثال28 ) برنامه ای بنویسید که حاصل عبارت روبرو را محاسبه نماید .
n 2 n1
C = n1 / n1 - n2 /n2
# include <stdio.h>
# include <conio.h>
Int power(inta,intb )
{
Int I,p;
P=1;
For (i=1;i<=b;i++);
P=p*a;
Return p;
}
Int fact (inta)
{
Int I,p;
F=1;
For (i=a;i>=1;i--)
F = f * I;
Return f ;
}
Int main( )
{
Int a,b ;
Float c ;
Clrscr ( );
Scanf(" %d %d \n ",&a,&b);
If (a<0 || b<0)
{
Printf(invalid);
Exit 0;
}
C= ( power (a,b)/fact( c ) ) – ( power (b,a)/ fact( c ) );
Printf("%f \n ",c);
Return (0);
}
مثال29 ) برنامه مثال بالا را با استفاده ازdiov بنویسید .
# include <stdio.h>
# include <conio.h>
Void power (int a,int b)
{
Int I,p;
P=1;
For( i=1;i<=b;i++)
P=p*a;
Printf( "%d",p );
}
Int main( )
{
Int a,b;
Scanf("%d %d \n ",&a,&b);
Power(a,b);
Return 0;
}