Program If, Else, If... Else
Program If, Else, If... Else
ELSE
#include <iostream.h>
#include <conio.h>
main ()
int a;
char rev;
do
clrscr();
cin>>a;
cout<<"\n";
if(a>0)
else if(a<0)
else
cout<<"Bilangan netral";
cout<<"ERROR :";
cout<<"\n\n";
cin>>rev;
while (rev=='Y'||rev=='y');
cout<<"\n";
getch();
}
PROGRAM ULANGAN HARIAN
#include <iostream.h>
#include <conio.h>
main()
char res;
float a,b,c,d;
do
clrscr();
cin>>a;
cin>>b;
c=a+b;
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<<endl;
cout<<"PILIHAN : ";
cin>>a;
cout<<endl;
if(a==1)
cin>>b;
pp=b*c;
else if(a==2)
cin>>b;
cin>>c;
sgt=b*c/2;
else
cout<<endl;
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<<endl;
cin>>hari;
cout<<endl;
if(hari==1)
else if(hari==2)
cout<<"hari ke 2 adalah hari selasa"<<endl;
else if(hari==3)
else if(hari==4)
else if(hari==5)
else if(hari==6)
else if(hari==7)
cout<<endl;
cout<<"\n\n";
cin>>res;
while (res=='Y'||res=='y');
cout<<"\n";
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<<endl;
cin>>a;
case 1: // dengan 1 :
cin>>b;
cin>>c;
d=b*c;
break; //putus;
case 2:
cin>>b;
cin>>c;
e=0.5*b*c;
break;
default: // lainnya:
cout<<endl;
cin>>i;
while (i=='y'||i=='Y');
cout<<endl;
cout<<"KELUAR . . .";
getch();
}
PROGRAM RUMAH MAKAN
#include <iostream>
#include <conio.h>
int main(){
cout<<"=====================================================================
======"<<endl<<endl;
cout<<"\n";
int a,b;
float byr,hrg,kem;
char res;
do{
cin>>a;
cout<<"\n\n";
switch(a){
case 1:
cout<<"AYAM GORENG"<<endl;
cin>>b;
byr=b*10000;
cin>>hrg;
kem=hrg-byr;
break;
case 2:
cout<<"NASI GORENG"<<endl;
cin>>b;
byr=b*8000;
cin>>hrg;
kem=hrg-byr;
break;
case 3:
cout<<"MIE PANGSIT"<<endl;
byr=b*10000;
cin>>hrg;
kem=hrg-byr;
break;
case 4:
cin>>b;
byr=b*12000;
cin>>hrg;
kem=hrg-byr;
break;
case 5:
cout<<"NASI CAMPUR"<<endl;
cin>>b;
byr=b*8000;
kem=hrg-byr;
break;
case 6:
cout<<"JUS JERUK"<<endl;
cin>>b;
byr=b*6000;
cin>>hrg;
kem=hrg-byr;
break;
case 7:
cout<<"AIR GELAS"<<endl;
cin>>b;
byr=b*500;
cin>>hrg;
kem=hrg-byr;
break;
default:
cout<<"\n";
cin>>res;
while(res=='y' ||res=='Y');
getch();
STRING
PROGRAM PASSWORD
#include <iostream.h>
#include <conio.h>
#include <string>
main()
string pass="a1";
string input;
cin>>input;
if(input==pass)
cout<<"Password benar"<<endl;
else
cout<<"Password salah"<<endl;
getch();
#include <iostream.h>
#include <conio.h>
#include <string>
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";
cin>>inputusr;
cin>>inputpw;
goto pro1;
cout<<endl;
cout<<endl;
else
cout<<"\n\n\n\n\n";
cout<<" -------------------------------------------\n";
cout<<endl;
cin>>mi;
while (mi=='y'||mi=='Y');
goto ans;
pro1:
system("cls");
cout<<" ||-----------------------------------------||"<<endl;
cout<<" ||-----------------------------------------||"<<endl;
cout<<endl;
cin>>a;
cout<<"===============================";
cout<<endl;
switch (a)
case 1:
cin>>b;
cin>>c;
d=b*c;
break;
case 2:
cin>>b;
cin>>c;
e=b*c/2;
break;
default:
}
cout<<"____________________";
cout<<endl;
cin>>i;
if (i=='y'||i=='Y'){
goto awal;
else
cout<<endl;
ans:
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;
cin>>masuk;
cin>>input;
if(masuk!=user)
if(input!=code)
cout<<"
======================================\n";
cin>>we;
if(we=='y'||we=='Y')
goto awal;
if(we=='t'||we=='T')
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";
cin>>pil;
switch(pil)
case 1:
cin>>ba;
cin>>ce;
cin>>kk;
cin>>se;
cin>>to;
ha=ba*50000;
if(ba>=5)
disc=ha*15/100;
seto=ha-disc;
if(seto>=1000000){
discep=seto*20/100;
m=seto-discep;
else if(seto>=500000){
discep=seto*25/100;
m=seto-discep;
else{
m=seto;
else
if(ha>=1000000){
discep=ha*25/100;
m=ha-discep;
else if(ha>=500000){
discep=ha*20/100;
m=ha-discep;
else{
m=ha;
cout<<" harga akhir =Rp."<<m<<endl;
ea=ce*100000;
if(ce>=4){
disd=ea*10/100;
seta=ea-disd;
if(seta>=500000){
discop=seta*20/100;
l=seta-discop;
else if(seta>=1000000){
discop=seta*25/100;
l=seta-discop;
else{
l=seta;
else{
if(ea>=500000){
discop=ea*20/100;
l=ea-discop;
else if(ea>=1000000){
discop=ea*25/100;
l=ea-discop;
else{
l=ea;
ad=kk*15000;
if(kk>=7){
dise=ad*25/100;
sete=ad-dise;
if(sete>=500000){
discip=sete*20/100;
n=sete-discip;
else if(sete>=1000000){
disco=sete*25/100;
n=sete-discip;
else{
n=sete;
else{
if(ad>=500000){
discip=ad*20/100;
n=ad-discip;
else if(ad>=1000000){
disco=ad*25/100;
n=ad-discip;
else{
n=ad;
fa=se*200000;
if(se==3){
disf=fa*20/100;
setu=fa-disf;
if(setu>=500000){
discep=setu*20/100;
o=setu-discep;
else if(setu>=1000000){
disco=setu*25/100;
o=setu-discep;
else{
o=setu;
else{
if(fa>=500000){
discep=fa*20/100;
o=fa-discep;
}
else if(fa>=1000000){
disco=fa*25/100;
o=fa-discep;
else{
o=fa;
la=to*20000;
cout<<" =======================================\n";
lanjut:
sub=m+l+n+o+la;
mem=sub*10/100;
total=sub-mem;
cout<<" =======================================\n";
cin>>byr;
kem=byr-total;
cout<<" ======================================\n";
break;
case 2:
cin>>ba;
cin>>ce;
cin>>kk;
cin>>se;
cin>>to;
ha=ba*50000;
if(ba>=5)
disc=ha*15/100;
seto=ha-disc;
if(seto>=1000000){
discep=seto*20/100;
m=seto-discep;
else if(seto>=500000){
discep=seto*25/100;
m=seto-discep;
else{
m=seto;
else
if(ha>=1000000){
discep=ha*25/100;
m=ha-discep;
else if(ha>=500000){
discep=ha*20/100;
m=ha-discep;
}
else{
m=ha;
ea=ce*100000;
if(ce>=4){
disd=ea*10/100;
seta=ea-disd;
if(seta>=500000){
discop=seta*20/100;
l=seta-discop;
else if(seta>=1000000){
discop=seta*25/100;
l=seta-discop;
else{
l=seta;
else{
cout<<" Celana "<<ce<<"*100000 =Rp."<<ea<<endl;
if(ea>=500000){
discop=ea*20/100;
l=ea-discop;
else if(ea>=1000000){
discop=ea*25/100;
l=ea-discop;
else{
l=ea;
ad=kk*15000;
if(kk>=7){
dise=ad*25/100;
sete=ad-dise;
if(sete>=500000){
discip=sete*20/100;
n=sete-discip;
}
else if(sete>=1000000){
disco=sete*25/100;
n=sete-discip;
else{
n=sete;
else{
if(ad>=500000){
discip=ad*20/100;
n=ad-discip;
else if(ad>=1000000){
disco=ad*25/100;
n=ad-discip;
else{
n=ad;
}
}
fa=se*200000;
if(se>=3){
disf=fa*20/100;
setu=fa-disf;
if(setu>=500000){
discep=setu*20/100;
o=setu-discep;
else if(setu>=1000000){
disco=setu*25/100;
o=setu-discep;
else{
o=setu;
else{
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;
else{
o=fa;
la=to*20000;
cout<<" =======================================\n";
sub=o+l+m+n+la;
total=sub;
cout<<" =======================================\n";
cin>>byr;
cout<<" ======================================\n";
break;
default:
cout<<endl;
cin>>we;
if(we=='y'||we=='Y')
goto beli;
if(we=='t'||we=='t')
goto akhir;
akhir:
getch();
MATERI FOR
#include <iostream>
#include <conio.h>
#include <stdlib.h>
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";
cin>>res;
while(res=='Y' ||res=='y');
return 0;
}
PROGRAM FIBONACCI
#include <iostream.h>
#include <conio.h>
main ()
getch();
#include <stdlib.h>
int main()
int a,b,n,limit,lemot,pil;
char res;
do
system("cls");
cout<<"\t\t\tPILIHAN : "<<endl;
cout<<"________________"<<endl<<endl;
cin>>pil;
if(pil==1)
cin>>limit;
cout<<endl;
cout<<endl;
for(n=1;n<=limit;n+=2)
cout<<n<<" ";
cout<<" "<<endl<<endl;
else if(pil==2)
{5
cin>>limit;
cout<<endl;
cout<<endl;
for(n=2;n<=limit;n+=2)
cout<<n<<" ";
cout<<" "<<endl<<endl;
else
cin>>res;
while(res=='Y' ||res=='y');
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";
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();
cin>>p;
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;
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;
cin>>inputusr;
cin>>inputpw;
cout<<" ||
======================================================= ||"<<endl<<endl;
goto awal;
cout<<endl;
cout<<endl;
else
cout<<"\n\n\n\n\n";
cout<<" -------------------------------------------\n";
cout<<endl;
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<<endl<<endl;
cin>>a;
nilai=a-b;
if(nilai>=500)
else if(nilai<50)
else
cout<<"_______________________________________________________";
cout<<endl<<endl;
cin>>i;
if (i=='y'||i=='Y')
goto awal;
else
cout<<endl;
ans:
getch();
}
MEMBENTUK POLA DENGAN LOOPING
Jawaban soal no.2:
#include <iostream.h>
#include <conio.h>
main()
int i,j,n;
cin >> n;
cout<<endl;
cout<<"---------"<<endl;
for (i=1;i<=n;i++) {
for (j=i;j<=n;j++) {
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;
cin>>masuk;
cin>>input;
if(masuk!=user)
if(input!=code)
cout<<"
======================================\n";
cin>>we;
if(we=='y'||we=='Y')
goto awal;
if(we=='t'||we=='T')
goto akhir;
program:
clrscr();
float a,b,c;
float pp,sgt;
char res;
do
clrscr();
cout<<endl;
cout<<endl;
cout<<"MENU : "<<endl;
cout<<"PILIHAN : ";
cin>>a;
cout<<endl;
if(a==1)
cin>>b;
cin>>c;
pp=b*c;
else if(a==2)
cin>>b;
cin>>c;
sgt=b*c/2;
else
cout<<endl;
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();
cin>>g;
cout<<"==============================="<<endl<<endl;
cin>>a;
cin>>b;
cin>>c;
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";
while (h=='y'||h=='Y');
getch();
}
#include <iostream.h>
#include <conio.h>
main()
cout<<”\n\n\n\n\n\n\n”;
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<<"======================================";
cout<<endl; cout<<endl;
cout<<endl;
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<<endl;
cin>>i;
while (i=='y'||i=='Y');
cout<<endl;
getch();
}
#include <iostream.h>
#include <conio.h>
int main()
int n;
int baris;
int kolom;
cin>>n;
cout<<endl;
cout<<"-------------"<<endl;
cout<<"*";
cout<<endl;
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<<"|============================================|"<<endl;
cout<<endl;
cin>>angka;
cout<<endl;
else
while(angka>=1000)
cout<<"M";
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<<endl;
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
gotoxy(60,7);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,16);cprintf ("---0-----0---");
delay(100);
textcolor(10);
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,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,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(" \\ |");
delay(100);
textcolor(10);
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(){
int A[5];
for(int c=0;c<5;c++){
cout<<"A["<<c<<"]=";
cin>>A[c];
for(int j=0;j<5;j++){
int Bil;
cin>>Bil;
for(int j=0;j<5;j++){
if(A[j]==Bil){
break;
getch();
return 0;
}
#include <iostream.h>
int main(){
int A[5];
cout<<"A["<<C<<"]=";cin>>A[C];
return 0;
}
#include <iostream.h>
#include <conio.h>
int main(){
cout<<"A["<<C<<"]= ";cin>>A[C];
getch();
return 0;
}
#include <iostream.h>
#include <conio.h>
int main(){
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;
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(){
cout<<A[C]<<endl;
int Bil;
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(){
cout<<A[C]<<endl;
getch();
return 0;
}
ARRAY BERSIFAT DATA BENTUKAN
#include <iostream.h>
#include <conio.h>
int main(){
Larik A={1,2,3,4,5};
getch();
return 0;
}
ARRAY DARI KARAKTER
#include <iostream.h>
#include <conio.h>
int main(){
cout<<A[C]<<"- ";
getch();
return 0;
}
BILA INGIN KELUARNYA TAMPIL
MENURUN
#include <iostream.h>
#include <conio.h>
int main(){
cout<<A[C]<<endl;
getch();
return 0;
}
POINTER DARI ARRAY
#include <iostream.h>
#include <conio.h>
int main(){
int A[5];
cout<<"Nilai P : "<<P<<endl;
cout<<'\n';
getch();
return 0;
}
ARRAY MULTI DIMENSI
//perkalian matrik
#include <iostream.h>
#include <conio.h>
int main(){
int A[3][2];
int B[2][3];
cin>>A[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];
cin>>A[j][i];
cout<<A[j][i]<<endl;
cin>>A[k][l];
cout<<A[k][l]<<endl;
getch();
return 0; }
#include <iostream.h>
#include <conio.h>
#include <string>
int main()
int n;
string nama[10],status[10];
int nilai[10];
char res;
do
clrscr();
cout<<"=========================================="<<endl;
cin>>n;
cout<<endl;
cout<<"=========================================="<<endl;
cout<<endl;
cout<<"Siswa ke-"<<i+1<<endl;
cin>>nama[i];
cin>>nilai[i];
if (nilai[i]<=50) {
status[i]="Tidak Lulus";
} else {
status[i]="Lulus";
cout<<endl;
cout<<"===================================================="<<endl;
cout<<"===================================================="<<endl;
cout<<"===================================================="<<endl;
cin>>res;
while(res=='y'||res=='Y');
getch();