Anda di halaman 1dari 96

PROGRAM IF,ELSE,IF...

ELSE
#include <iostream.h>

#include <conio.h>

main ()

int a;

char rev;

do

clrscr();

cout<<"Masukan angka : ";

cin>>a;

cout<<"\n";

if(a>0)

cout<<"angaka "<<a<<" adalah bilangan positif ";

else if(a<0)

cout<<"Angka "<<a<<" adalah bilangan negatif ";

else

cout<<"Bilangan netral";

cout<<"ERROR :";

cout<<"\n\n";

cout<<"REVIND ? (Y/T) : ";

cin>>rev;

while (rev=='Y'||rev=='y');
cout<<"\n";

cout<<"ENTER to close. . .";

getch();

}
PROGRAM ULANGAN HARIAN
#include <iostream.h>

#include <conio.h>

main()

char res;

float a,b,c,d;

do

clrscr();

cout<<"NILAI ULANGAN HARIAN 1 : ";

cin>>a;

cout<<"NILAI ULANGAN HARIAN 2 : ";

cin>>b;

c=a+b;

cout<<"jumlah nilai : "<<c<<endl<<endl;

d=c/2;

cout<<"rata-rata : "<<d<<endl<<endl;

if(d>=90)

cout<<"NILAI :A";

else if (d>=80)

cout<<"NILAI :B";

else if (d<70)

cout<<"NILAI :C";

cout<<"\n\n";
cout<<"Ingin Mengulang ? (y/n) \n";

cin>>res;

while(res=='y'||res=='Y');

cout<<"TERIMA KASIH"<<endl;

getch();

}
PROGRAM MENGHITUNG LUAS
Dengan if dan else
#include <iostream.h>

#include <conio.h>

main()

float a,b,c;

float pp,sgt;

char d;

do

clrscr();

cout<<"MENU : "<<endl;

cout<<"1. Luas Persegi Panjang "<<endl;

cout<<"2. Luas Segitiga "<<endl;

cout<<endl;

cout<<"PILIHAN : ";

cin>>a;

cout<<endl;

if(a==1)

cout<<"Masukan Panjang :";

cin>>b;

cout<<"Masukan Lebar :";


cin>>c;

pp=b*c;

cout<<"LUAS PERSEGI PANJANG : "<<pp<<endl;

else if(a==2)

cout<<"Masukan ALAS :";

cin>>b;

cout<<"Masukan TINGGI :";

cin>>c;

sgt=b*c/2;

cout<<"LUAS SEGITIGA : "<<sgt<<endl;

else

cout<<"Data Tidak Ditemukan !!!";

cout<<endl;

cout<<"RESET DATA ? (Y/T) :";

cin>>d;

while (d=='y'||d=='Y');

cout<<endl;

cout<<"KELUAR . . .";

getch();

}
PROGRAM HARI
#include <iostream.h>

#include <conio.h>

main()

int hari;

char res;

do

clrscr();

cout<<"Data"<<endl;

cout<<"1 = > Senin "<<endl;

cout<<"2 = > Selasa "<<endl;

cout<<"3 = > Rabu "<<endl;

cout<<"4 = > Kamis "<<endl;

cout<<"5 = > Jumat "<<endl;

cout<<"6 = > Sabtu "<<endl;

cout<<"7 = > Minggu "<<endl;

cout<<endl;

cout<<"masukan angaka: ";

cin>>hari;

cout<<endl;

if(hari==1)

cout<<"hari ke 1 adalah hari senin"<<endl;

else if(hari==2)
cout<<"hari ke 2 adalah hari selasa"<<endl;

else if(hari==3)

cout<<"hari ke 3 adalah hari rabu"<<endl;

else if(hari==4)

cout<<"hari ke 4 adalah hari kamis"<<endl;

else if(hari==5)

cout<<"hari ke 5 adalah hari jumat"<<endl;

else if(hari==6)

cout<<"hari ke 6 adalah hari sabtu"<<endl;

else if(hari==7)

cout<<"hari ke 7 adalah hari minggu"<<endl;

cout<<endl;

cout<<"\n\n";

cout<<"RESET ? (Y/T) : ";

cin>>res;

while (res=='Y'||res=='y');

cout<<"\n";

cout<<"ENTER to close. . .";

getch();

}
PROGRAM SWITCH
#include <iostream.h>

#include <conio.h>

main()

int a,b,c;

float d,e;

char i;

do

clrscr();

cout<<"MENU :"<<endl;

cout<<endl;

cout<<"1. Luas Persegi Panjang"<<endl;

cout<<"2. Luas Segitiga "<<endl;

cout<<endl;

cout<<"Masukan Pilihan : ";

cin>>a;

switch(a) // cocok (a)

case 1: // dengan 1 :

cout<<"Masukan panjang : ";

cin>>b;

cout<<"Masukan lebar : ";

cin>>c;
d=b*c;

cout<<"LUAS PERSEGI PANJANG : "<<d<<endl;

break; //putus;

case 2:

cout<<"Masukan alas : ";

cin>>b;

cout<<"Masukan tinggi : ";

cin>>c;

e=0.5*b*c;

cout<<"LUAS SEGITIGA : "<<e<<endl;

break;

default: // lainnya:

cout<<"File not found....";

cout<<endl;

cout<<"RESET DATA ? (Y/T) : ";

cin>>i;

while (i=='y'||i=='Y');

cout<<endl;

cout<<"KELUAR . . .";

getch();

}
PROGRAM RUMAH MAKAN
#include <iostream>

#include <conio.h>

int main(){

cout<<" WARUNG BARU BUKA"<<endl;

cout<<" PENGEN UNTUNG"<<endl;

cout<<" Chef Xtreme Ma'nyos Pokoknya"<<endl;

cout<<" Jl. Tidak Terlihat, NO.007"<<endl;

cout<<"=====================================================================
======"<<endl<<endl;

cout<<"Menu Makanan : Harga :"<<endl;

cout<<"1. AYAM GORENG Rp. 10.000"<<endl;

cout<<"2. NASI GORENG Rp. 8.000"<<endl;

cout<<"3. MIE PANGSIT Rp. 10.000"<<endl;

cout<<"4. AYAM LALAPAN + NASI Rp. 12.000"<<endl;

cout<<"5. NASI CAMPUR Rp. 8.000"<<endl;

cout<<"6. JUS JERUK Rp. 6.000"<<endl;

cout<<"7. AIR GELAS Rp. 500"<<endl;

cout<<"\n";

int a,b;

float byr,hrg,kem;

char res;

do{

cout<<"MASUKKAN PILHAN ANDA : ";

cin>>a;

cout<<"\n\n";
switch(a){

case 1:

cout<<"AYAM GORENG"<<endl;

cout<<"Masukkan Jumlah : ";

cin>>b;

byr=b*10000;

cout<<"Total Harga : Rp. "<<byr<<endl;

cout<<"DIBAYAR : Rp. ";

cin>>hrg;

kem=hrg-byr;

cout<<"KEMBALIAN : Rp. "<<kem<<endl;

break;

case 2:

cout<<"NASI GORENG"<<endl;

cout<<"Masukkan Jumlah : ";

cin>>b;

byr=b*8000;

cout<<"Total Harga : Rp. "<<byr<<endl;

cout<<"DIBAYAR : Rp. ";

cin>>hrg;

kem=hrg-byr;

cout<<"KEMBALIAN : Rp. "<<kem<<endl;

break;

case 3:

cout<<"MIE PANGSIT"<<endl;

cout<<"Masukkan Jumlah : ";


cin>>b;

byr=b*10000;

cout<<"Total Harga : Rp. "<<byr<<endl;

cout<<"DIBAYAR : Rp. ";

cin>>hrg;

kem=hrg-byr;

cout<<"KEMBALIAN : Rp. "<<kem<<endl;

break;

case 4:

cout<<"AYAM LALAPAN + NASI"<<endl;

cout<<"Masukkan Jumlah : ";

cin>>b;

byr=b*12000;

cout<<"Total Harga : Rp. "<<byr<<endl;

cout<<"DIBAYAR : Rp. ";

cin>>hrg;

kem=hrg-byr;

cout<<"KEMBALIAN : Rp. "<<kem<<endl;

break;

case 5:

cout<<"NASI CAMPUR"<<endl;

cout<<"Masukkan Jumlah : ";

cin>>b;

byr=b*8000;

cout<<"Total Harga : Rp. "<<byr<<endl;

cout<<"DIBAYAR : Rp. ";


cin>>hrg;

kem=hrg-byr;

cout<<"KEMBALIAN : Rp. "<<kem<<endl;

break;

case 6:

cout<<"JUS JERUK"<<endl;

cout<<"Masukkan Jumlah : ";

cin>>b;

byr=b*6000;

cout<<"Total Harga : Rp. "<<byr<<endl;

cout<<"DIBAYAR : Rp. ";

cin>>hrg;

kem=hrg-byr;

cout<<"KEMBALIAN : Rp. "<<kem<<endl;

break;

case 7:

cout<<"AIR GELAS"<<endl;

cout<<"Masukkan Jumlah : ";

cin>>b;

byr=b*500;

cout<<"Total Harga : Rp. "<<byr<<endl;

cout<<"DIBAYAR : Rp. ";

cin>>hrg;

kem=hrg-byr;

cout<<"KEMBALIAN : Rp. "<<kem<<endl;

break;
default:

cout<<"MENU TIDAK ADA";

cout<<"\n";

cout<<"MASIH ADA Y/T :";

cin>>res;

while(res=='y' ||res=='Y');

cout<<"terima kasih sudah berkunjung ^_^";

getch();

STRING
PROGRAM PASSWORD
#include <iostream.h>

#include <conio.h>

#include <string>

main()

string pass="a1";

string input;

cout<<"Masukan Password :";

cin>>input;

if(input==pass)

cout<<"Password benar"<<endl;

else

cout<<"Password salah"<<endl;

getch();

#include <iostream.h>

#include <conio.h>
#include <string>

using namespace std;

main()

string pass="a1";

string user="admin";

string inputpw,inputusr;

int a,b,c;

float d,e;

char i,pro1,mi,ans,awal;

awal:

do

system("cls");

cout<<"\n\n\n\n\n";

cout<<" Masukan username : ";

cin>>inputusr;

cout<<" Masukan password : ";

cin>>inputpw;

if (inputpw==pass && inputusr==user)

goto pro1;

else if (inputusr==user && inputpw!=pass)

cout<<endl;

cout<<" ... Maaf Password Anda Salah ..."<<endl;

cout<<" _______________________ "<<endl;


}

else if (inputusr!=user && inputpw==pass)

cout<<endl;

cout<<" ... Maaf Username Anda Salah ..."<<endl;

cout<<" _______________________ "<<endl;

else

cout<<"\n\n\n\n\n";

cout<<" -------------------------------------------\n";

cout<<" Maaf Password dan Username Salah"<<endl;

cout<<endl;

cout<<" Ingin mengulangi ? (Y/T): ";

cin>>mi;

while (mi=='y'||mi=='Y');

goto ans;

pro1:

system("cls");

cout<<" ||-----------------------------------------||"<<endl;

cout<<" || === SELAMAT DATANG DI PROGRAMKU === ||"<<endl;

cout<<" ||-----------------------------------------||"<<endl;

cout<<endl;

cout<<" PILIHAN PROGRAM : "<<endl;

cout<<" 1. Luas Persegi panjang "<<endl;

cout<<" 2. Luas Segitiga "<<endl;


cout<<endl<<endl;

cout<<">> Masukan Pilihan : ";

cin>>a;

cout<<"===============================";

cout<<endl;

switch (a)

case 1:

cout<<" HITUNG LUAS PERSEGI PANJANG\n\n";

cout<<" Masukan Panjang : ";

cin>>b;

cout<<" Masukan Lebar : ";

cin>>c;

d=b*c;

cout<<" Luas Persegi Panjang : "<<d<<endl<<endl;

break;

case 2:

cout<<" HITUNG LUAS SEGITIGA\n\n";

cout<<" Masukan Alas : ";

cin>>b;

cout<<" Masukan Lebar : ";

cin>>c;

e=b*c/2;

cout<<" Luas Segitiga : "<<e<<endl;

break;

default:

cout<<" Data tidak ditemukan ... !!! "<<endl;

}
cout<<"____________________";

cout<<endl;

cout<<" Ingin Inputkan password lagi ? (Y/T) : ";

cin>>i;

if (i=='y'||i=='Y'){

goto awal;

else

cout<<endl;

ans:

cout<<"Enter untuk Keluar . . . "<<endl;

getch();

PROGRAM SUPERMARKET
#include <iostream>

#include <conio.h>

#include <string>

main()

string code="a2";

string input;

string user="a1";

string masuk;

char we;

{
awal:

clrscr();

cout<<endl;

cout<<endl;

cout<<endl;

cout<<endl;

cout<<endl;

cout<<endl;

cout<<endl;

cout<<endl;

cout<<" ~UserName :";

cin>>masuk;

cout<<" ~Password :";

cin>>input;

if(masuk==user && input==code)


goto beli;

if(masuk!=user)

cout<<" Maaf Username Anda Salah\n";

if(input!=code)

cout<<" Maaf Password Anda Salah\n";

cout<<"
======================================\n";

cout<<" Ingin Mencoba Kembali(Y/T):";

cin>>we;

if(we=='y'||we=='Y')

goto awal;

if(we=='t'||we=='T')

cout<<"Terima Kasih Telah Mencoba";

goto akhir;

beli:

clrscr();

int
pil,ea,ad,fa,la,seta,sete,seto,setu,setp,set,l,m,n,o,a,b,c,d,ba,ce,kk,se,to,ha,kem,byr,sub,disco
,discop,discap,discip,discep,mem,total,disc,disd,dise,disf;

cout<<endl;

cout<<endl;

cout<<" Pembeli:\n";

cout<<" 1. Member\n";

cout<<" 2. Non Member\n";


cout<<" Masukan pilihan jenis pembeli:";

cin>>pil;

switch(pil)

case 1:

cout<<" Baju :";

cin>>ba;

cout<<" Celana :";

cin>>ce;

cout<<" Kaos kaki :";

cin>>kk;

cout<<" Sepatu :";

cin>>se;

cout<<" Topi :";

cin>>to;

ha=ba*50000;

if(ba>=5)

disc=ha*15/100;

seto=ha-disc;

cout<<" Baju "<<ba<<"*50000 =Rp."<<seto<<endl;

if(seto>=1000000){

discep=seto*20/100;

m=seto-discep;

cout<<" harga ahir =Rp."<<m<<endl;


}

else if(seto>=500000){

discep=seto*25/100;

m=seto-discep;

cout<<" harga akhir =Rp."<<m<<endl;

else{

m=seto;

cout<<" harga akhir =Rp."<<m<<endl;

else

cout<<" Baju "<<ba<<"*50000 =Rp."<<ha<<endl;

if(ha>=1000000){

discep=ha*25/100;

m=ha-discep;

cout<<" harga ahir =Rp."<<m<<endl;

else if(ha>=500000){

discep=ha*20/100;

m=ha-discep;

cout<<" harga akhir =Rp."<<m<<endl;

else{

m=ha;
cout<<" harga akhir =Rp."<<m<<endl;

ea=ce*100000;

if(ce>=4){

disd=ea*10/100;

seta=ea-disd;

cout<<" Celana "<<ce<<"*100000 =Rp."<<seta<<endl;

if(seta>=500000){

discop=seta*20/100;

l=seta-discop;

cout<<" harga ahir =Rp."<<l<<endl;

else if(seta>=1000000){

discop=seta*25/100;

l=seta-discop;

cout<<" harga akhir =Rp."<<l<<endl;

else{

l=seta;

cout<<" harga akhir =Rp."<<l<<endl;

else{

cout<<" Celana "<<ce<<"*100000 =Rp."<<ea<<endl;

if(ea>=500000){
discop=ea*20/100;

l=ea-discop;

cout<<" harga ahir =Rp."<<l<<endl;

else if(ea>=1000000){

discop=ea*25/100;

l=ea-discop;

cout<<" harga akhir =Rp."<<l<<endl;

else{

l=ea;

cout<<" harga akhir =Rp."<<l<<endl;

ad=kk*15000;

if(kk>=7){

dise=ad*25/100;

sete=ad-dise;

cout<<" Kaos Kaki "<<kk<<"*15000=Rp."<<sete<<endl;

if(sete>=500000){

discip=sete*20/100;

n=sete-discip;

cout<<" harga akhir =Rp."<<n<<endl;

else if(sete>=1000000){

disco=sete*25/100;
n=sete-discip;

cout<<" harga akhir =Rp."<<n<<endl;

else{

n=sete;

cout<<" harga akhir =Rp."<<n<<endl;

else{

cout<<" Kaos Kaki "<<kk<<"*15000=Rp."<<ad<<endl;

if(ad>=500000){

discip=ad*20/100;

n=ad-discip;

cout<<" harga akhir =Rp."<<n<<endl;

else if(ad>=1000000){

disco=ad*25/100;

n=ad-discip;

cout<<" harga akhir =Rp."<<n<<endl;

else{

n=ad;

cout<<" harga akhir =Rp."<<n<<endl;

fa=se*200000;
if(se==3){

disf=fa*20/100;

setu=fa-disf;

cout<<" Sepatu "<<se<<"*200000 =Rp."<<setu<<endl;

if(setu>=500000){

discep=setu*20/100;

o=setu-discep;

cout<<" harga akhir =Rp."<<o<<endl;

else if(setu>=1000000){

disco=setu*25/100;

o=setu-discep;

cout<<" harga akhir =Rp."<<o<<endl;

else{

o=setu;

cout<<" harga akhir =Rp."<<o<<endl;

else{

cout<<" Sepatu "<<se<<"*200000 =Rp."<<fa<<endl;

if(fa>=500000){

discep=fa*20/100;

o=fa-discep;

cout<<" harga akhir =Rp."<<o<<endl;

}
else if(fa>=1000000){

disco=fa*25/100;

o=fa-discep;

cout<<" harga akhir =Rp."<<o<<endl;

else{

o=fa;

cout<<" harga akhir =Rp."<<o<<endl;

la=to*20000;

cout<<" Topi "<<to<<"*20000 =Rp."<<la<<endl;

cout<<" =======================================\n";

lanjut:

sub=m+l+n+o+la;

cout<<" Sub Total =Rp."<<sub<<endl;

mem=sub*10/100;

cout<<" Discount =Rp."<<disco<<endl;

cout<<" Discount Member =Rp."<<mem<<endl;

cout<<" -------------------------------------- -\n";

total=sub-mem;

cout<<" Total =Rp."<<total<<endl;

cout<<" =======================================\n";

cout<<" Pembayaran =Rp.";

cin>>byr;

cout<<" Total =Rp."<<total<<endl;


cout<<" -------------------------------------- -\n";

kem=byr-total;

cout<<" Kembalian =Rp."<<kem<<endl;

cout<<" ======================================\n";

break;

case 2:

cout<<" Baju :";

cin>>ba;

cout<<" Celana :";

cin>>ce;

cout<<" Kaos kaki :";

cin>>kk;

cout<<" Sepatu :";

cin>>se;

cout<<" Topi :";

cin>>to;

ha=ba*50000;

if(ba>=5)

disc=ha*15/100;

seto=ha-disc;

cout<<" Baju "<<ba<<"*50000 =Rp."<<seto<<endl;

if(seto>=1000000){

discep=seto*20/100;
m=seto-discep;

cout<<" harga ahir =Rp."<<m<<endl;

else if(seto>=500000){

discep=seto*25/100;

m=seto-discep;

cout<<" harga akhir =Rp."<<m<<endl;

else{

m=seto;

cout<<" harga akhir =Rp."<<m<<endl;

else

cout<<" Baju "<<ba<<"*50000 =Rp."<<ha<<endl;

if(ha>=1000000){

discep=ha*25/100;

m=ha-discep;

cout<<" harga ahir =Rp."<<m<<endl;

else if(ha>=500000){

discep=ha*20/100;

m=ha-discep;

cout<<" harga akhir =Rp."<<m<<endl;

}
else{

m=ha;

cout<<" harga akhir =Rp."<<m<<endl;

ea=ce*100000;

if(ce>=4){

disd=ea*10/100;

seta=ea-disd;

cout<<" Celana "<<ce<<"*100000 =Rp."<<seta<<endl;

if(seta>=500000){

discop=seta*20/100;

l=seta-discop;

cout<<" harga ahir =Rp."<<l<<endl;

else if(seta>=1000000){

discop=seta*25/100;

l=seta-discop;

cout<<" harga akhir =Rp."<<l<<endl;

else{

l=seta;

cout<<" harga akhir =Rp."<<l<<endl;

else{
cout<<" Celana "<<ce<<"*100000 =Rp."<<ea<<endl;

if(ea>=500000){

discop=ea*20/100;

l=ea-discop;

cout<<" harga ahir =Rp."<<l<<endl;

else if(ea>=1000000){

discop=ea*25/100;

l=ea-discop;

cout<<" harga akhir =Rp."<<l<<endl;

else{

l=ea;

cout<<" harga akhir =Rp."<<l<<endl;

ad=kk*15000;

if(kk>=7){

dise=ad*25/100;

sete=ad-dise;

cout<<" Kaos Kaki "<<kk<<"*15000=Rp."<<sete<<endl;

if(sete>=500000){

discip=sete*20/100;

n=sete-discip;

cout<<" harga akhir =Rp."<<n<<endl;

}
else if(sete>=1000000){

disco=sete*25/100;

n=sete-discip;

cout<<" harga akhir =Rp."<<n<<endl;

else{

n=sete;

cout<<" harga akhir =Rp."<<n<<endl;

else{

cout<<" Kaos Kaki "<<kk<<"*15000=Rp."<<ad<<endl;

if(ad>=500000){

discip=ad*20/100;

n=ad-discip;

cout<<" harga akhir =Rp."<<n<<endl;

else if(ad>=1000000){

disco=ad*25/100;

n=ad-discip;

cout<<" harga akhir =Rp."<<n<<endl;

else{

n=ad;

cout<<" harga akhir =Rp."<<n<<endl;

}
}

fa=se*200000;

if(se>=3){

disf=fa*20/100;

setu=fa-disf;

cout<<" Sepatu "<<se<<"*200000 =Rp."<<setu<<endl;

if(setu>=500000){

discep=setu*20/100;

o=setu-discep;

cout<<" harga akhir =Rp."<<o<<endl;

else if(setu>=1000000){

disco=setu*25/100;

o=setu-discep;

cout<<" harga akhir =Rp."<<o<<endl;

else{

o=setu;

cout<<" harga akhir =Rp."<<o<<endl;

else{

cout<<" Sepatu "<<se<<"*200000 =Rp."<<fa<<endl;

if(fa>=500000){

discep=fa*20/100;

o=fa-discep;
cout<<" harga akhir =Rp."<<o<<endl;

else if(fa>=1000000){

disco=fa*25/100;

o=fa-discep;

cout<<" harga akhir =Rp."<<o<<endl;

else{

o=fa;

cout<<" harga akhir =Rp."<<o<<endl;

la=to*20000;

cout<<" Topi "<<to<<"*20000 =Rp."<<la<<endl;

cout<<" =======================================\n";

sub=o+l+m+n+la;

cout<<" Sub Total =Rp."<<sub<<endl;

cout<<" -------------------------------------- -\n";

total=sub;

cout<<" Discount =Rp."<<disco<<endl;

cout<<" Total =Rp."<<total<<endl;

cout<<" =======================================\n";

cout<<" Pembayaran =Rp.";

cin>>byr;

cout<<" Total =Rp."<<total<<endl;

cout<<" -------------------------------------- -\n";


kem=byr-total;

cout<<" Kembalian =Rp."<<kem<<endl;

cout<<" ======================================\n";

break;

default:

cout<<"Maaf Pelayanan Tersebut tidak ada";

cout<<endl;

cout<<" Ingin Berbelanja Kembali(Y/T):";

cin>>we;

if(we=='y'||we=='Y')

goto beli;

if(we=='t'||we=='t')

cout<<"Terima Kasih Telah Berbelanja";

goto akhir;

akhir:

getch();

MATERI FOR
#include <iostream>

#include <conio.h>

#include <stdlib.h>

using namespace std;

int main()

int n,limit;

char res;

do

system("cls");

cout<<"Limit :";

cin>>limit;

cout<<"\n\n";

cout<<"Hasil: \n\n";

cout<<"======================================================== \n\n";

for(n=1;n<=limit;n+=2)

cout<<n<<" ";

cout<<"\n\n";

cout<<"Input Again?(Y/T) :";

cin>>res;

while(res=='Y' ||res=='y');

cout<<"Press any key...";

return 0;

}
PROGRAM FIBONACCI
#include <iostream.h>
#include <conio.h>

main ()

int N1, N2, Suku, a, b, c;


cout <<"Masukan Deret Pertama Fibonacci = ";
cin   >>N1;
cout <<"Masukan Julah Deret Fibonaci Yang Akan Dideret = ";
cin   >>Suku;
cout <<"Deret Pertama = "<<N1<<endl;
N2 = N1+1;
cout <<"Deret Ke Dua  = "<<N2<<endl;
cout <<Suku<<" Deret Fibonacci \n";
a = N1; b = N2;
cout <<a<<endl<<b<<endl;
for (int i = 3; i<=Suku; i++)
{
c=a+b;
a = b;
b = c;
cout<<c<<endl;
}
cout<<"\n\n";

getch();

PROGRAM FOR BIL GANJIL GENAP


#include <iostream>
#include <conio.h>

#include <stdlib.h>

using namespace std;

int main()

int a,b,n,limit,lemot,pil;

char res;

do

system("cls");

cout<<"\t\t\tPILIHAN : "<<endl;

cout<<"\t\t\t1. Angka Ganjil "<<endl;

cout<<"\t\t\t2. Angka Genap "<<endl;

cout<<"________________"<<endl<<endl;

cout<<"Masukan Pilihan : ";

cin>>pil;

if(pil==1)

cout<<"Masukan Batasan :";

cin>>limit;

cout<<endl;

cout<<"Bilangan Ganjil 1 sampai "<<limit<<endl;

cout<<endl;

for(n=1;n<=limit;n+=2)

cout<<n<<" ";

cout<<" "<<endl<<endl;

else if(pil==2)
{5

cout<<"Masukan Batasan :";

cin>>limit;

cout<<endl;

cout<<"Bilangan Genap 2 sampai "<<limit<<endl;

cout<<endl;

for(n=2;n<=limit;n+=2)

cout<<n<<" ";

cout<<" "<<endl<<endl;

else

cout<<"Data Eror ! !";

cout<<"Apakah anda ingin memasukan data lagi? (Y/T) :";

cin>>res;

while(res=='Y' ||res=='y');

cout<<"Press any key...";

getch();

PROGRAM KALKULATOR
#include <iostream.h>

#include <conio.h>
main ()

float a1,a2,j,r,l,b;

char res;

do

clrscr();

cout<<"angka 1:";

cin>>a1;

cout<<"angka 2:";

cin>>a2;

cout<<"============================"<<endl;

j=a1+a2;

cout<<"Jumlah :"<<j<<endl;

r=a1-a2;

cout<<"Kurang :"<<r<<endl;

l=a1*a2;

cout<<"Kali :"<<l<<endl;

b=a1/a2;

cout<<"Bagi :"<<b<<endl;

cout<<"\n\n";

cout<<"Ingin Mengulang ? (y/t) \n";

cin>>res;

while(res=='y'||res=='Y');

cout<<"Tekan Enter"<<endl;

getch();

}
PROGRAM SURGA NERAKA
#include <iostream.h>

#include <conio.h>

main()
{

float p,b,r;

char res,s,n;

do

clrscr();

cout<<" Masukan pahala:";

cin>>p;

cout<<" Masukan buruk:";

cin>>b;

cout<<"=============================================="<<endl;

r=p-b;

cout<<"result:"<<r<<endl;

if(r>=50)

cout<<"Surga"<<s<<endl;

else if(r<=50)

cout<<"Neraka"<<n<<endl;

cout<<"Ingin Mengulang ? (y/n) \n";

cin>>res;

while(res=='y'||res=='Y');

cout<<"Tekan Enter"<<endl;

getch();

}
#include <iostream.h>

#include <conio.h>

#include <string>

main()

{
string user="admin";

string pass="a1";

string inputpw,inputusr;

char nama[10];

float a,b,c,d,e,f,nilai;

char i,pro1,mi,ans,awal;

do

system("cls");

cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<en
dl;

cout<<" ||
======================================================= ||"<<endl;

cout<<" Masukan username :";

cin>>inputusr;

cout<<" Masukan password :";

cin>>inputpw;

cout<<" ||
======================================================= ||"<<endl<<endl;

if (inputpw==pass && inputusr==user)

goto awal;

else if (inputusr==user && inputpw!=pass)

cout<<endl;

cout<<" ... Maaf Password Anda Salah ..."<<endl;

cout<<" _______________ "<<endl;


}

else if (inputusr!=user && inputpw==pass)

cout<<endl;

cout<<" ... Maaf Username Anda Salah ..."<<endl;

cout<<" _______________ "<<endl;

else

cout<<"\n\n\n\n\n";

cout<<" -------------------------------------------\n";

cout<<" Maaf Password dan Username Salah"<<endl;

cout<<endl;

cout<<" Ingin mengulangi ? (Y/T): ";

cin>>mi;

while (mi=='y'||mi=='Y');

goto ans;

awal:

//codingan

system("cls");

cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;

cout<<" INSTAN KARMA "<<endl;

cout<<endl<<endl;

cout<<" masukkan pahala :";

cin>>a;

cout<<" masukkan buruk:";


cin>>b;

nilai=a-b;

cout<<" pahala anda:"<<nilai<<endl;

if(nilai>=500)

cout<<" ANDA MASUK SORGA"<<endl;

else if(nilai<50)

cout<<" ANDA MASUK NERAKA"<<endl;

else

cout<<"data tidak ditemukan "<<endl;

//code yg akan diisi

cout<<"_______________________________________________________";

cout<<endl<<endl;

cout<<" Ingin Inputkan password lagi ? (Y/T) : ";

cin>>i;

if (i=='y'||i=='Y')

goto awal;

else

cout<<endl;

ans:

cout<<"Enter untuk Keluar . . . "<<endl;

getch();

}
MEMBENTUK POLA DENGAN LOOPING
Jawaban soal no.2:

#include <iostream.h>

#include <conio.h>

main()

int i,j,n;

cout<<"inputkan jumlah bintang : ";

cin >> n;
cout<<endl;

cout<<"Bentuk Pola :"<<endl;

cout<<"---------"<<endl;

for (i=1;i<=n;i++) {

for (j=i;j<=n;j++) {

cout << "*";

cout << endl;

getch();

}
LATIHAN
#include <iostream>

#include <conio.h>

#include <string>

main()

string code="31";

string input;

string user="can";

string masuk;

char we;

awal:

clrscr();

cout<<endl;

cout<<endl;

cout<<endl;

cout<<endl;

cout<<endl;

cout<<endl;

cout<<endl;

cout<<endl;

cout<<" UserName :";

cin>>masuk;

cout<<" Password :";

cin>>input;

if(masuk==user && input==code)


goto program;

if(masuk!=user)

cout<<" Maaf Username Anda Salah\n";

if(input!=code)

cout<<" Maaf Password Anda Salah\n";

cout<<"
======================================\n";

cout<<" Ingin Mencoba Kembali(Y/T):";

cin>>we;

if(we=='y'||we=='Y')

goto awal;

if(we=='t'||we=='T')

cout<<"Terima Kasih Telah Mencoba";

goto akhir;

program:

clrscr();

float a,b,c;

float pp,sgt;

char res;

do

clrscr();

cout<<endl;

cout<<endl;

cout<<"MENU : "<<endl;

cout<<"1. Luas Persegi Panjang"<<endl;

cout<<"2. Luas Segitiga "<<endl;


cout<<endl;

cout<<"PILIHAN : ";

cin>>a;

cout<<endl;

if(a==1)

cout<<"Masukan Panjang :";

cin>>b;

cout<<"Masukan Lebar :";

cin>>c;

pp=b*c;

cout<<"LUAS PERSEGI PANJANG : "<<pp<<endl;

else if(a==2)

cout<<"Masukan ALAS :";

cin>>b;

cout<<"Masukan TINGGI :";

cin>>c;

sgt=b*c/2;

cout<<"LUAS SEGITIGA : "<<sgt<<endl;

else

cout<<"Data Tidak Ditemukan !!!";

cout<<endl;

cout<<"Ingin Mengulang ? (y/n) \n";

cin>>res;

}
while(res=='y'||res=='Y');

cout<<"Tekan Enter"<<endl;

getch();

akhir:

return 0;

}
#include <iostream.h>

#include <conio.h>

main()

float a,b,c,d,e,f;

char g[10];

char h;

do

clrscr();

cout<<"Masukan Nama : ";

cin>>g;

cout<<"==============================="<<endl<<endl;

cout<<" >>Masukan nilai ulangan 1 :";

cin>>a;

cout<<" >>Masukan nilai ulangan 2 :";

cin>>b;

cout<<" >>Masukan nilai ulangan 3 :";

cin>>c;

cout<<" >>Masukan nilai ulangan 4 :";

cin>>d;

e=a+b+c+d;

f=e/4;

cout<<"\n";

cout<<"=============================="<<endl<<endl;

cout<<"Hai "<<g<<" jumlah nilaimu adalah "<<e<<" dan rata-rata nilai adalah "<<f<<endl;

cout<<"\n";

cout<<"Ingin masukan data lagi (Y/T) : ";


cin>>h;

while (h=='y'||h=='Y');

cout<<"press any key to close program.....";

getch();

}
#include <iostream.h>

#include <conio.h>

main()

int i, first, second, next;

cout<<”\n\n\n\n\n\n\n”;

cout<<” value : “<<second<<” “;

for(i=1;i<10;i++)

next=first+second;

first=second;

second=next;

cout<<next<<” “;

getch();

}
#include <iostream.h>

#include <conio.h>

main()

int z,baris,kolom;

char i;

do

clrscr();

cout<<" MAIN MENU:"<<endl;

cout<<"======================================";

cout<<endl; cout<<endl;

cout<<" 1.Baris = 4, kolom = 1 "<<endl;

cout<<" 2.Baris = 2, kolom = 1 "<<endl;

cout<<endl;

cout<<"PILIH Menu : ";

cin>>z;

if(z==1)

clrscr();

for(baris=1;baris<=4;baris++)

cout<<" * ";

cout<<endl;

else if(z==2)

{
clrscr();

for(baris=1;baris<=2;baris++)

for(kolom=1;kolom<=4;kolom++)

cout<<" + ";

cout<<endl;

else

cout<<"MENU YANG DIPILIH TIDAK TERSEDIA";

cout<<endl;

cout<<"Ingin masukan angka lagi (y/t)? ";

cin>>i;

while (i=='y'||i=='Y');

cout<<endl;

cout<<"Tekan Enter 1x untuk KELUAR ";

getch();

}
#include <iostream.h>

#include <conio.h>

int main()

int n;

int baris;

int kolom;

cout<<"inputkan jumlah bintang : ";

cin>>n;

cout<<endl;

cout<<"-------------"<<endl;

for(baris=1; baris<=n; baris++)

for(kolom=1; kolom<=baris; kolom++)

cout<<"*";

cout<<endl;

for(baris=1; baris<=n; baris++)

for(kolom=baris+1;kolom<=n;kolom++)

cout<<"*";

cout<<endl;

getch();

}
PROGRAM PENGKONVERSI ANGKA
NUMERIC KE ROMAWI
#include <iostream.h>

#include <conio.h>

int main()

int angka;

char i;

do

cout<<"|============================================|"<<endl;

cout<<"|PROGRAM PENGKONVERSI ANGKA NUMERIC KE ROMAWI|"<<endl;

cout<<"|============================================|"<<endl;

cout<<endl;

cout<<"Silahkan Masukan Angka ( 1...3999):";

cin>>angka;

cout<<endl;

if(angka <1 || angka > 3999)

cout<<"Angka harus dalam jangkauan 1...3999";

else

while(angka>=1000)

cout<<"M";

angka = angka - 1000;

if(angka >=500)
{

if(angka >=900)

cout<<"CM";

angka = angka-900;

else

cout<<"D";

angka= angka-500;

while(angka>=100)

if(angka>=400)

cout<<"CD";

angka=angka-400;

else

cout<<"C";

angka=angka-100;

if(angka>=50)

if(angka>=90)
{

cout<<"XC";

angka=angka-90;

else

cout<<"L";

angka=angka-50;

while(angka >=10)

if (angka >=40)

cout<<"XL";

angka=angka-40;

else

cout<<"X";

angka=angka-10;

if(angka>=5)

if(angka==9)

cout<<"IX";
angka=angka-9;

else

cout<<"V";

angka=angka-5;

while(angka>=1)

if(angka==4)

cout<<"IV";

angka=angka-4;

else

cout<<"I";

angka=angka-1;

cout<<"\n"; //pindah baris

cout<<endl;

cout<<"INGIN INPUTKAN DATA LAGI (Y/T) ( Huruf Kapital )?";

cin>>i;

while(i=='Y'||i=='y');
cout<<"Tekan enter untuk keluar.....";

getch();

}
PROGRAM ANIMASI
#include <conio.h>

#include <dos.h>

delay(int a);

delay(int a)

for(int x=0;x<a*100;x++)

for(int y=0;y<a*100;y++)

{}

main ()

_setcursortype(_NOCURSOR);

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");


gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);
gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");


gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");
textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");


gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();
gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");


gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);
clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);
gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(4,13);cprintf (" ___ ");

gotoxy(4,14);cprintf ("_____| \\__");

gotoxy(4,15);cprintf ("| |");

gotoxy(4,16);cprintf ("---0-----0---");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");
delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(43,8);cprintf (" __");

gotoxy(43,9);cprintf ("| |");

gotoxy(43,10);cprintf(" | |");

gotoxy(43,11);cprintf(" 0 --");

gotoxy(43,12);cprintf(" | |");

gotoxy(43,13);cprintf(" | |");

gotoxy(43,14);cprintf(" 0 //");

gotoxy(43,15);cprintf(" | |");

gotoxy(43,16);cprintf(" ____");

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

clrscr();

gotoxy(1,17);cprintf("-------------------------------------------------------------------------------");

textcolor(9);

gotoxy(43,12);cprintf(" ----0----0----");
gotoxy(43,13);cprintf(" | |");

gotoxy(43,14);cprintf(" -- -----");

gotoxy(43,15);cprintf(" \\ |");

gotoxy(43,16);cprintf(" --- ");

delay(100);

textcolor(10);

gotoxy(60,7);cprintf (" () ");

gotoxy(60,8);cprintf (" (()) ");

gotoxy(60,9);cprintf (" ((())) ");

gotoxy(60,10);cprintf(" ((((())))) ");

gotoxy(60,11);cprintf(" (((((()))))) ");

gotoxy(60,12);cprintf(" (((((((())))))))");

gotoxy(60,13);cprintf(" | |");

gotoxy(60,14);cprintf(" | |");

gotoxy(60,15);cprintf(" | |");

delay(100);

sleep(5);

clrscr();

textcolor(9);

gotoxy(30,5);cprintf("$$$$");

delay(100);

textcolor(1);

gotoxy(33,5);cprintf("$$$$");

delay(100);

textcolor(2);

gotoxy(36,5);cprintf("$$$$");

delay(100);

textcolor(3);
gotoxy(39,5);cprintf("$$$$");

delay(100);

textcolor(4);

gotoxy(42,5);cprintf("$$$$");

delay(100);

textcolor(6);

gotoxy(45,5);cprintf("$$$$");

delay(100);

textcolor(8);

gotoxy(48,5);cprintf("$$$$");

delay(100);

textcolor(10);

gotoxy(51,5);cprintf("$$$$");

delay(100);

textcolor(11);

gotoxy(54,6);cprintf("$$");

delay(100);

textcolor(12);

gotoxy(54,7);cprintf("$$");

delay(100);

textcolor(3);

gotoxy(54,8);cprintf("$$");

delay(100);

textcolor(6);

gotoxy(54,9);cprintf("$$");

delay(100);

textcolor(9);

gotoxy(54,10);cprintf("$$");
delay(100);

textcolor(6);

gotoxy(54,11);cprintf("$$");

delay(100);

textcolor(2);

gotoxy(51,12);cprintf("$$$$");

delay(100);

textcolor(4);

gotoxy(48,12);cprintf("$$$$");

delay(100);

textcolor(3);

gotoxy(45,12);cprintf("$$$$");

delay(100);

textcolor(9);

gotoxy(42,12);cprintf("$$$$");

delay(100);

textcolor(10);

gotoxy(39,12);cprintf("$$$$");

delay(100);

textcolor(11);

gotoxy(36,12);cprintf("$$$$");

delay(100);

textcolor(1);

gotoxy(33,12);cprintf("$$$$");

delay(100);

textcolor(5);

gotoxy(30,12);cprintf("$$$$");

delay(100);
textcolor(3);

gotoxy(29,11);cprintf("$$");

delay(100);

textcolor(4);

gotoxy(29,10);cprintf("$$");

delay(100);

textcolor(3);

gotoxy(29,9);cprintf("$$");

delay(100);

textcolor(3);

gotoxy(29,8);cprintf("$$");

delay(100);

textcolor(3);

gotoxy(29,7);cprintf("$$");

delay(100);

textcolor(3);

gotoxy(29,6);cprintf("$$");

sleep(8);

clrscr();

return 1;

getch();

}
ARRAY
#include <iostream.h>

#include <conio.h>

int main(){

//Deklarasi sebuah array dengan nama A

int A[5];

//Memasukan nilai ke dalam elemen array

for(int c=0;c<5;c++){

cout<<"A["<<c<<"]=";

cin>>A[c];

cout<<"Menampilakan nilai dalam elemen array"<<endl;

for(int j=0;j<5;j++){

cout<<"Nilai elemen array ke-"<<j+1<<"adalah"<<A[j]<<endl;

int Bil;

cout<<"Masukan nilai yang dicari:";

cin>>Bil;

for(int j=0;j<5;j++){

if(A[j]==Bil){

cout<<"Elemen yang dicari terdapat dalam indeks ke-"<<j;

break;

getch();

return 0;

}
#include <iostream.h>

int main(){

// mendeklarasikan sebuah array dengan nama A

int A[5];

//memasukkan nilai ke dalam elemen array

for (int C=0;C<5;C++){

cout<<"A["<<C<<"]=";cin>>A[C];

return 0;

}
#include <iostream.h>

#include <conio.h>

int main(){

int A[5]; // mendeklarasikan mendeklarasikan sebuah array dengan nama A

//memasukkan memasukkan nilai ke dalam elemen array

for (int C=0;C<5;C++){

cout<<"A["<<C<<"]= ";cin>>A[C];

cout<<"menampilkan nilai dalam elemen array"<<endl;

for (int j=0;j<5;j++){

cout<<"Nilai elemen array ke -"<<j+1<<"adalah"<<A[j]<<endl;

getch();

return 0;

}
#include <iostream.h>

#include <conio.h>

int main(){

int A[5]={1,2,3,4,5}; // mendeklarasikan sebuah array dengan nilainya

cout<<"menampilkan nilai dalam elemen array"<<endl;

cout<<"Sebelum perubahan"<<endl;

cout<<"A[0] = "<<A[0]<<endl;

cout<<"A[1] = "<<A[1]<<endl;

cout<<"A[2] = "<<A[2]<<endl;

cout<<"A[3] = "<<A[3]<<endl;

cout<<"A[4] = "<<A[4]<<endl;

//mengubah mengubah elemen 1 dan 2

A[0] = 100;

A[1] = 2000;

cout<<"Setelah perubahan"<<endl;

cout<<"A[0] = "<<A[0]<<endl;

cout<<"A[1] = "<<A[1]<<endl;

cout<<"A[2] = "<<A[2]<<endl;

cout<<"A[3] = "<<A[3]<<endl;

cout<<"A[4] = "<<A[4]<<endl;

getch();

return 0;

}
SEQUENTIAL SEARCHING
#include <iostream.h>

#include <conio.h>

int main(){

int A[5]={1,2,3,4,5}; // mendeklarasikan sebuah array dengan nilainya

cout<<"nilai pada elemen array"<< array"<<endl;

for(int for(int C=0;C<5;C++){

cout<<A[C]<<endl;

int Bil;

cout<<"Masukkan nilai yang dicari : "; cin>>Bil;

for (int j=0;j<5;j++){

if (A[j] == Bil){

cout<< "elemen yang dicari terdapat terdapat dalam indeks ke- "<<j;

break;

getch();

return 0;

}
ARRAY BERSIFAT KONSTAN
#include <iostream.h>

#include<conio.h>

int main(){

// mendeklarasikan sebuah array konstan dengan nilainya

int const A[5]={1,2,3,4,5};

cout<<"nilai pada elemen array"<< array"<<endl;

for(int for(int C=0;C<5;C++){

cout<<A[C]<<endl;

getch();

return 0;

}
ARRAY BERSIFAT DATA BENTUKAN
#include <iostream.h>

#include <conio.h>

int main(){

// mendeklarasikan sebuah tipe data berbentuk array dengan nama Larik

typedef int Larik[5];

//mendeklarasikan variabel A dengan tipe data Larik dengan nilainya

Larik A={1,2,3,4,5};

cout<<"nilai pada elemen array"<< array"<<endl;

for(int for(int C=0;C<5;C++){

cout<<"elemen ke "<<C<<" = “<<A[C]<<endl;

getch();

return 0;

}
ARRAY DARI KARAKTER
#include <iostream.h>

#include <conio.h>

int main(){

// mendeklarasikan array A dengan tipe data karakter

char A[4] = {'A','L','I','\0'};

cout<<"nilai pada elemen array"<< array"<<endl;

for(int for(int C=0;C<3;C++){

cout<<A[C]<<"- ";

getch();

return 0;

}
BILA INGIN KELUARNYA TAMPIL
MENURUN
#include <iostream.h>

#include <conio.h>

int main(){

// mendeklarasikan array A dengan tipe data karakter

char A[4] = {'A','L','I','\0'};

cout<<"nilai pada elemen array"<< array"<<endl;

for(int for(int C=0;C<3;C++){

cout<<A[C]<<endl;

getch();

return 0;

}
POINTER DARI ARRAY
#include <iostream.h>

#include <conio.h>

int main(){

int A[5];

int*P = A; //mendeklarasikan pointer P yang menunjukkan array A

cout<<"Nilai &A[0] : "<<&A[0]<<endl;

// menunjukkan alamat array A yang pertama, yaitu A[0]

cout<<"Nilai P : "<<P<<endl;

cout<<'\n';

cout<<"menunjukkan menunjukkan alamat array A"<< array A"<<endl;

for (int x=0;x<5;x++){

cout<<"Nilai &A["<<x<<"]: "<<&A[x]<<endl;

getch();

return 0;

}
ARRAY MULTI DIMENSI
//perkalian matrik

#include <iostream.h>

#include <conio.h>

int main(){

int A[3][2];

int B[2][3];

cout<<"masukkan masukkan nilai A[1][1] : ";

cin>>A[1][1];

cout<<"masukkan masukkan nilai B[1][1] : ";

cin>>B[1][1];

cout<<A[1][1]<<endl;

cout<<B[1][1<<endl;

getch();

return 0;

}
ARRAY MULTI DIMENSI
//perkalian perkalian

#include <iostream.h>

#include <conio.h>

int main(){

int A[3][2];

int B[2][3];

//perulangan untuk mengisi nilai array A

for (int j=1;j<4;j++){

for (int i=1;i<3;i++){

cout<<"masukkan masukkan nilai A ["<<j<<"]["<<i<<"] : ";

cin>>A[j][i];

cout<<"nilai A ["<<j<<"]["<<i<<"] : ";

cout<<A[j][i]<<endl;

//perulangan untuk mengisi nilai array B

for (int l=1;l<4;l++){

for (int k=1;k<3;k++){

cout<<"masukkan nilai B ["<<k<<"]["<<l<<"] : ";

cin>>A[k][l];

cout<<"nilai B ["<<k<<"]["<<l<<"] : ";

cout<<A[k][l]<<endl;

getch();

return 0; }
#include <iostream.h>

#include <conio.h>

#include <string>

using namespace std;

int main()

int n;

string nama[10],status[10];

int nilai[10];

char res;

do

clrscr();

cout<<"PROGRAM KELULUSAN SISWA"<<endl;

cout<<"=========================================="<<endl;

cout<<"Masukan Banyak Siswa = ";

cin>>n;

cout<<endl;

cout<<"=========================================="<<endl;

for (int i=0; i<n; i++) {

cout<<endl;

cout<<"Siswa ke-"<<i+1<<endl;

cout<<"Masukan Nama Siswa = ";

cin>>nama[i];

cout<<"Masukan Nilai Siswa = ";

cin>>nilai[i];

if (nilai[i]<=50) {

status[i]="Tidak Lulus";
} else {

status[i]="Lulus";

cout<<endl;

cout<<"DAFTAR NILAI SISWA"<<endl;

cout<<"===================================================="<<endl;

cout<<"No Nama Nilai Keterangan "<<endl;

cout<<"===================================================="<<endl;

for (int i=0; i<n;i++) {

cout<<i+1<<" "<<nama[i]<<" "<<nilai[i]<<" "<<status[i]<<endl;

cout<<"===================================================="<<endl;

cout<<"Ingin Mengulang ? (y/n) \n";

cin>>res;

while(res=='y'||res=='Y');

cout<<"Tekan Enter untuk Keluar...."<<endl;

getch();

Anda mungkin juga menyukai