Jumat, 08 April 2016

BAB 6

DEV C++


#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
int g;
cout<<"-----------------------------------"<<endl;
cout<<"Menentukan Nilai Ganjil dan Genap"<<endl;
cout<<"-----------------------------------"<<endl;
cout<<"Masukan nilai g : ";
cin>>g;
if (g % 2==0)
cout<<"Bilangan Genap"<<endl;
else
cout<<"Bilangan Ganjil"<<endl;
cout<<"------------------------------------"<<endl;
return 0;
}

RAPTOR


DEV C++

#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
class persegi {
public :
persegi ();
void input();
void proses();

private :
int p;
int l;
int hasil;
};
persegi::persegi(){
cout<<"=================================\n";
cout<<"Menghitung Luas Persegi Panjang\n";
cout<<"=================================\n";
}

void persegi::input (){
cout<<"Masukkan Panjang : ";
cin>>p;
cout<<"Masukkan Lebar : ";
cin>>l;

}

void persegi::proses(){
hasil = p*l;
cout<<"Luas : "<<hasil;
}


int main(int argc, char** argv) {

persegi Prsg;
Prsg.input();
Prsg.proses();
return 0;
}


RAPTOR


DEV C++


#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
class persegi {
public :
persegi ();
void input();
void proses();

private :
int p;
int l;
int hasil;
};
persegi::persegi(){
cout<<"=================================\n";
cout<<"Menghitung Keliling Persegi Panjang\n";
cout<<"=================================\n";
}

void persegi::input (){
cout<<"Masukkan Panjang : ";
cin>>p;
cout<<"Masukkan Lebar : ";
cin>>l;

}

void persegi::proses(){
hasil = 2*(p+l);
cout<<"Keiling : "<<hasil;
}

int main(int argc, char** argv) {
persegi Prsg;
Prsg.input();
Prsg.proses();
return 0;
}

RAPTOR

DEV C++


#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
class lingkaran {
public :
lingkaran ();
void input();
void proses();

private :
int r;
float volume;
};

lingkaran::lingkaran(){
cout<<"=================================\n";
cout<<"Menghitung Volume Lingkaran \n";
cout<<"=================================\n";
}

void lingkaran::input (){
cout<<"Masukkan Jari-Jari : ";
cin>>r;
}

void lingkaran::proses(){
volume=(4/(float)3)*(22/(float)7)*r*r*r;
cout<<"Volume : "<<volume;
}

int main(int argc, char** argv) {
lingkaran Lkrn;
Lkrn.input();
Lkrn.proses();

return 0;
}


RAPTOR


DEV C++


#include <iostream>
using namespace std;
class segitiga {
public :
segitiga ();
void input();
void proses();

private :
int a;
int t;
int hasil;
};
segitiga::segitiga(){
cout<<"=================================\n";
cout<<"\n\nLuas Segitiga Siku-siku : \n"<<endl;
cout<<"=================================\n";
}

void segitiga::input (){
cout<<"Masukkan Alas : ";
cin>>a;
cout<<"Masukkan Tinggi : ";
cin>>t;

}

void segitiga::proses(){
hasil = (a*t)/2;
cout<<"Luas : "<<hasil;
}

main ()
{

segitiga Sgtg;
Sgtg.input();
Sgtg.proses();
return 0;
}

RAPTOR


DEV C++


#include <cstdlib>
#include <iostream>

using namespace std;
class segitiga {
public :
segitiga ();
void input();
void proses();

private :
int a;
int b;
int c;
int keliling;
};
segitiga::segitiga(){
cout<<"=================================\n";
cout<<"Menghitung Keliling Segitiga\n";
cout<<"=================================\n";
}

void segitiga::input (){
cout<<"Masukkan Panjang Sisi A = ";
cin>>a;
cout<<"Masukkan Panjang Sisi B = ";
cin>>b;
cout<<"Masukkan Panjang Sisi C = ";
cin>>c;

}

void segitiga::proses(){
keliling=a+b+c;;
cout<<"Keliling : "<<keliling;
}


int main(int argc, char *argv[]){
segitiga sgtga;
sgtga.input();
sgtga.proses();
return 0;
}

RAPTOR


DEV C++



#include <iostream>
using namespace std;
class segitiga {
public :
segitiga ();
void input();
void proses();

private :
int l;
int a;
int tinggi;
};
segitiga::segitiga(){
cout<<"=================================\n";
cout<<"Menghitung Tinggi Segitiga\n";
cout<<"=================================\n";
}

void segitiga::input (){
cout<<"masukkan luas segitiga : ";
cin>>l;
cout<<"masukkan nilai alas segitiga : ";
cin>>a;

}

void segitiga::proses(){
tinggi = 2*l/a;
cout<<"Tinggi : "<<tinggi;
}

int main(int argc, char** argv) {

segitiga sgtga;
sgtga.input();
sgtga.proses();
return 0;
}

RAPTOR


DEV C++


#include <iostream>
#include <conio.h>
using namespace std;

int main(){
    int i,r, n, C, x;
    int fak_n=1;
    int fak_x=1;
    int fak_r=1;
    cout<<"Masukan nilai r: ";cin>>r;
    cout<<"Masukan nilai n: ";cin>>n;
    x=n-r;
    for (i=1; i<=x; i++){
        fak_x = fak_x * i;}
    for (i=1; i<=n; i++){
        fak_n = fak_n * i;}
    for (i=1; i<=r; i++){
        fak_r = fak_r * i;}
 
    cout<<"\nFaktor dari "<<n<<" adalah\t  : "<<fak_n;
    cout<<"\nFaktor dari "<<r<<" adalah\t  : "<<fak_r;
    cout<<"\nFaktor dari n-r ("<<x<<") adalah: "<<fak_x;
 
    C= fak_n /(fak_x *fak_r);
    cout<<"\n\nMari kita hitung : "<<fak_n<<" / ("<<fak_r<<" X "<<fak_x<<")";
    cout<<"\n\nMaka Kombinasinya: "<<C;
    getch();
    return 0;
    }

DEV C++

#include <iostream>
#include <conio.h>
using namespace std;

int main(){
    int i,r, n, P, x;
    int fak_n=1;
    int fak_x=1;
   
    cout<<"Masukkan nilai r: ";cin>>r;
    cout<<"Masukkan nilai n: ";cin>>n;
    x=n-r;
    for (i=1; i<=x; i++){
        fak_x = fak_x * i;}
    for (i=1; i<=n; i++){
        fak_n = fak_n * i;}
   
    cout<<"\nFaktor dari "<<n<<" adalah: "<<fak_n;
    cout<<"\nFaktor dari n-r ("<<x<<") adalah: "<<fak_x;
   
    P= fak_n /(fak_x);
    cout<<"\n\nMaka Permutasinya: "<<P;
    getch();
    return 0;
    }


Tidak ada komentar:

Posting Komentar