#include <conio.h>
#include <iostream.h>
int faktorial (int x)
{
int i=1;
int f=1;
while (i<=x)
{
f=f*i;
i++;
}
return (f);
}
main ()
{
char perulangan='y';
int pilihan;
int permutasi;
int kombinasi;
int bilangan;
int n;
int r;
while (perulangan)
{
clrscr();
cout<<"MENU PILIHAN PERHITUNGAN MATEMATIKA DISKRIT"<<endl;
cout<<"============================================"<<endl<<endl;
cout<<"1. FAKTORIAL"<<endl;
cout<<"2. PERMUTASI"<<endl;
cout<<"3. KOMBINASI"<<endl;
cout<<"4. EXIT"<<endl;
cout<<"\n============================================"<<endl<<endl;
cout<<"\nPILIHAN MENU : ";cin>>pilihan;
if (pilihan==1)
{
clrscr();
cout<<"PERHITUNGAN FAKTORIAL"<<endl;
cout<<"=====================\n\n";
cout<<"INPUTKAN NILAI N : ";cin>>n;
cout<<"HASIL FAKTORIAL : "<<faktorial(n);
cout<<endl;
cout<<"\n\nPRESS ANY KEY TO RETURN TO THE START MENU : ";cin>>perulangan;
}
else if (pilihan==2)
{
clrscr();
cout<<"PERHITUNGAN PERMUTASI"<<endl;
cout<<"=====================\n\n";
cout<<"INPUTKAN NILAI N : ";cin>>n;
cout<<"INPUTKAN NILAI R : ";cin>>r;
bilangan = n-r;
permutasi=faktorial(n)/faktorial(bilangan);
cout<<"HASIL PERMUTASI : "<<permutasi;
cout<<endl;
cout<<"\n\nPRESS ANY KEY TO RETURN TO THE START MENU : ";cin>>perulangan;
}
else if (pilihan==3)
{
clrscr();
cout<<"PERHITUNGAN KOMBINASI"<<endl;
cout<<"=====================\n\n";
cout<<"INPUTKAN NILAI N : ";cin>>n;
cout<<"INPUTKAN NILAI R : ";cin>>r;
bilangan = n-r;
kombinasi=faktorial(n)/(faktorial(bilangan)*faktorial(r));
cout<<"HASIL KOMBINASI : "<<kombinasi;
cout<<endl;
cout<<"\n\nPRESS ANY KEY TO RETURN TO THE START MENU : ";cin>>perulangan;
}
else if (pilihan==4)
{
cout<<"\n\n============================================";
cout<<"\n\nANDA TELAH MENGAKHIRI MENU PERHITUNGAN INI";
break;
}
else
{
clrscr();
cout<<"KEYWORD YANG ANDA INPUTKAN SALAH, PERIKSA KEMBALI";
cout<<endl;
cout<<"\n=================================================";
cout<<"\n\nPRESS ANY KEY TO RETURN TO THE START MENU : ";cin>>perulangan;
}
}
getch();
}
OUTPOT PROGRAM
Subscribe to:
Post Comments (Atom)
CONTOH CODING LINKED LIST MENGGUNAKAN BORLAND C++
CONTOH CODING LINKED LIST MENGGUNAKAN BORLAND C++ #include<stdlib.h> #include<conio.h> #include<iostream.h> struc...
-
#include <iostream.h> #include <conio.h> #include <fstream.h> #include <stdio.h> #include <stdlib.h> struct pa...
-
#include <iostream.h> #include <conio.h> #include <fstream.h> #include <stdio.h> #include <iomanip.h> #include...
-
#include <iostream.h> #include <iomanip.h> #include <stdio.h> #include <conio.h> void coba(); struct rumahsakit { ...
No comments:
Post a Comment