C++ Binomial
00.26 | Author: Sueb Zains
Program binomial ini adalah salah satu tugas dari mata kuliah statistika. Silahkan untuk memahami source codenya ya....hehe

#include <conio.h>
#include <iostream.h>
#include <math.h>
float fak(float n){
   float f;

    if (n<=1){
        f=1;
    }else{

        f=n*fak(n-1);
    }
    return (f);
   }
void main()
{
   int x,n;
   float px,qnx,P_Bin,p,Cnx;
    float fak(float n);
   cout<<"Masukkan Nilai x : ";cin>>x;
   cout<<"Masukkan Nilai p : ";cin>>p;
   cout<<"Masukkan Nilai n : ";cin>>n;
    cout<<endl;
    if (n>x){
        Cnx = fak(n)/(fak(n-x)*fak (x));
        cout<<"Cnx = "<<Cnx<<endl;
    }else if (n<x){
        cout<<"Data tidak memenuhi syarat!!!";
    }
   px = pow(p,x);
   cout<<"px = "<<px<<endl;
   qnx = pow ((1-p),(n-x));
   cout<<"qnx = "<<qnx<<endl;
   cout<<endl;
   P_Bin = Cnx*px*qnx;
   cout<<"P_Bin = "<<P_Bin;


   getch();
}


Semoga bermanfaat untuk anda. :)
This entry was posted on 00.26 and is filed under . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

0 komentar: