Blogger templates

Matrik

Tidak ada komentar
Program Matrik dengan 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 i,j,hasil[2][2];
int A[2][2]={6,5,4,3},B[2][2]={6,5,4,3};

cout<<"Isi variabel data adalah "<<endl;
cout<<"--------------------------\n\n";
cout<<"  MATRIK 1  |  MATRIK 2 "<<endl<<endl;

for(i=0;i<2;i++){
for(j=0;j<2;j++)
cout<<" "<<A[i][j]<<" ";}
cout<<" ";

for(i=0;i<2;i++){
for(j=0;j<2;j++)
cout<<" "<<B[i][j]<<" ";}
cout<<endl<<endl;

cout<<"HASIL : ";
for(i=0;i<2;i++){
for(j=0;j<2;j++){
hasil[i][j]=A[i][j]+B[i][j];
cout<<" "<<hasil[i][j]<<" ";
}
}

return 0;
}


Tidak ada komentar :

Posting Komentar

Pangkat

Tidak ada komentar
Program Pangkat dengan 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 i, hasil,a,n;
hasil=1;
cout<<"Program Menghitung Pangkat"<<endl<<endl;
cout<<"Masukkan nilai A : ";
cin>>a;
cout<<"Masukkan nilai N : ";
cin>>n;
for(i=1;i<=n;i++){
hasil = hasil * a;
}
cout<<"Hasil A pangkat N adalah : "<<hasil;
cout<<endl;
return 0;
}



Program Pangkat dengan Pascal





Tidak ada komentar :

Posting Komentar

Deret Fibonacci

Tidak ada komentar
Program Deret Fibonacci dengan 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 a, b, x, y, i;

cout<<"Program Deret Fibonacci"<<endl<<endl;
    cout<<"Masukkan bilangan : ";cin>>a;
     x=1;y=1;
     cout<<x<<endl<<y<<endl;
     for(int b=3; b<=a; b++)
    {
    i = x + y;
    x = y;
    y = i;

     cout<<i<<endl;
     }
return 0;
}




Program Deret Fibonacci Dengan Pascal



Tidak ada komentar :

Posting Komentar

Tukar 3 Bilangan

Tidak ada komentar
Program Tukar 3 Bilangan dengan 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 A,B,C,D;

 cout<<"A = ";cin>>A;
 cout<<"B = ";cin>>B;
 cout<<"C = ";cin>>C;

 D=A;
 A=B;
 B=C;
 C=D;

 cout<<endl;
 cout<<"A = "<<A<<endl;
 cout<<"B = "<<B<<endl;
 cout<<"C = "<<C<<endl;
 return 0;

}



Tidak ada komentar :

Posting Komentar

Wujud Air

Tidak ada komentar
Program Wujud Air dengan 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) {
float A;

cout<<"A :";
cin>>A;

if(A>=0 && A<=100)
cout<<"Cair";

else if(A>100)
cout<<"Uap";

else
cout<<"Padat";

return 0;
}




Tidak ada komentar :

Posting Komentar

Program Membaca Bilangan Bulat Untuk Menampilkan kalau bilangan itu ganjil

Tidak ada komentar
Program Membaca Bilangan Bulat Untuk Menampilkan kalau bilangan itu ganjil dengan 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 x;

cout<<"Masukkan bilangan : ";cin>>x;

if(x%2==1)
cout<<"Ganjil"<<endl;

return 0;
}


Tidak ada komentar :

Posting Komentar

Program Menghitung Faktorial

Tidak ada komentar
Program menghitung Faktorial dengan Dev C++

#include <cstdlib>
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int faktorial (int a){
if(a==1)
return 1;

else
return a*faktorial(a-1);
}
int main(int argc, char** argv) {
int n;
cout<<"\tProgram penghitung Faktorial"<<endl;
cout<<"\t============================"<<endl;
cout<<"\nMasukkan angka yang ingin di faktorialkan = ";
cin>>n;
cout<<"\nFaktorial "<<n<<"!="<<faktorial(n)<<endl;

return 0;
}



Tidak ada komentar :

Posting Komentar