Buatlah fungsi untuk mentukan nilai N! Dan fungsi
utama yang memanggil fungsi diatas untuk menentukan
nilai C dimana C = (8!*12!)/4!
faktorial dengan fungsi nilai
#include
#include
f(double A,double B,double C,double D);
void main()
{ clrscr();
double b,n1,n2,n3;
double h1, h2, h3, h4;
cout<<"n1= ";cin>>n1;cout<<"n2= ";cin>>n2;cout<<"n3= ";cin>>n3;
h1=1;
for (b=n1; b>=1; b--)
{
h1=h1 * b;
}
h2=1;
for (b=n2; b>=1; b--)
{
h2=h2 * b;
}
h3=1;
for (b=n3; b>=1; b--)
{
h3=h3 * b;
}
f(h1,h2,h3,h4);
getch();
}
f(double A, double B, double C ,double D)
{
D=(A*B)/(C);
cout<<"Nilai C = "<
Dengan Fungsi ACUAN
faktorial dengan fungsi acuan
#include
#include
f(double *A,double *B,double *C,double *D);
void main()
{ clrscr();
double b,n1,n2,n3;
double h1, h2, h3, h4;
cout<<"n1= ";cin>>n1;cout<<"n2= ";cin>>n2;cout<<"n3= ";cin>>n3;
h1=1;
for (b=n1; b>=1; b--)
{
h1=h1 * b;
}
h2=1;
for (b=n2; b>=1; b--)
{
h2=h2 * b;
}
h3=1;
for (b=n3; b>=1; b--)
{
h3=h3 * b;
}
f(&h1,&h2,&h3,&h4);
getch();
}
f(double *A, double *B, double *C ,double *D)
{
*D=((*A)*(*B))/(*C);
cout<<"Nilai C = "<<*D<
Posting Lebih Baru Posting Lama Beranda
0 komentar:
Posting Komentar