LATIHAN 5
#include <iostream.h>
#include <conio.h>
void main()
{int pilihan;
cout<<"Silahkan pilih satu item \n\n";
cout<<"1. Pilihan 1 \n";
cout<<"2. Pilihan 2 \n";
cout<<"3. Pilihan 3 \n";
cout<<"4. Pilihan 4 \n";
cin>>pilihan;
switch(pilihan)
{ case 1:
cout<<"Anda memilih nomor 1 \n";
break;
case 2:
cout<<"Anda memilih nomor 2 \n";
break;
case 3:
cout<<"Anda memilih nomor 3 \n";
break;
case 4:
cout<<"Anda memilih nomor 4 \n";
break;
default:
cout<<"Anda salah pilih \n";
break;
}
cin>>pilihan;}
LATIHAN 6
#include <iostream.h>
#include <conio.h>
void main()
{
awal:
clrscr();
int pilihan;
char input;
cout<<"Silahkan pilih satu item \n\n";
cout<<"1. Tugas 1 \n";
cout<<"2. Tugas 2 \n";
cout<<"3. Tugas 3 \n";
cout<<"4. Tugas 4 \n";
cout<<"Masukan pilihan [1..4]:";cin>>pilihan;
switch(pilihan)
{ case 1:
{
int usia;
clrscr();
cout<<"Berapa usia anda :";cin>>usia;
if (usia<17)
cout<<"Anda belum dewasa"<<endl;
else
cout<<"Anda dewasa"<<endl;
cout<<"Apakah anda ingin mengulang [Y/T] ?";cin>>input;
if (input=='y' || input=='Y')
goto awal;
}
break;
case 2:
{
int bil;
clrscr();
cout<<"Masukan sebuah bilangan :";cin>>bil;
if (bil%2==0)
cout<<"Bilangan genap"<<endl;
else
cout<<"Bilangan ganjil"<<endl;
cout<<"Apakah anda ingin mengulang [Y/T] ?";cin>>input;
if (input=='y' || input=='Y')
goto awal;
}
break;
case 3:
{
int a;
clrscr();
cout<<"Masukan kode jabatan :";cin>>a;
if (a==1)
{cout<<"Golongan anda I"<<endl;
cout<<"Gaji anda Rp.1000"<<endl;
cout<<"Anda orang miskin";}
else
{cout<<"Golongan anda II"<<endl;
cout<<"Gaji anda Rp.2000"<<endl;
cout<<"Anda orang kaya";}
cout<<"Apakah anda ingin mengulang [Y/T] ?";cin>>input;
if (input=='y' || input=='Y')
goto awal;
}
break;
case 4:
{
int a;
clrscr();
cout<<"Masukan nilai antara 1 sampai 4=";cin>>a;
if (a==1)
cout<<"Nilai 1 yang dipilih";
else
if (a==2)
cout<<"Nilai 2 yang dipilih";
else
if (a==3)
cout<<"Nilai 3 yang dipilih";
else
cout<<"Nilai 4 yang dipilih";
}
cout<<"Apakah anda ingin mengulang [Y/T] ?";cin>>input;
if (input=='y' || input=='Y')
goto awal;
break;
default :
cout<<"Anda salah pilih \n";cin>>pilihan;
break;
getch();
}}
WARUNG PROGRAM
Minggu, 29 Maret 2015
Senin, 02 Maret 2015
Latihan 5
#include <iostream.h>
#include <conio.h>
Void main()
{ int pilihan ;
cout<<Silakan Pilih satu item \n\n”;
cout<<”1.pilihan 1 \n”;
cout<<”2.pilihan 2 \n”;
cout<<”3.pilihan 3 \n”;
cout<<”4.pilihan 4 \n”;
cout<<”Masukkan Pilihan [1.4] : “;
cin>>pilihan;
switch (pilihan)
{ case 1 :
cout<<”Anda Memilih Nomor 1 \n”;
break;
case 2 :
cout<<”Anda Memilih Nomor 2 \n”;
break;{ case 3 :
case 3 :
cout<<”Anda Memilih Nomor 3 \n”;
break;
case 4 :
cout<<”Anda Memilih Nomor 4 \n”;
break;
default:
cout<<”Anda salah pilih \n”;
break;
}
}
Menentukan Nilai
Latihan 4
#include <iostream.h>
#include <conio.h>
void main()
{int a;
clrscr();
cout<<"Masukkan nilai antara 1 sampai 4 =";
cin>>a;
if(a==1)
cout<<"Nilai 1 yang dipilih";
else if(a==2)
cout<<"Nilai 2 yang dipilih";
else if(a==3)
cout<<"Nilai 3 yang diplih";
else
cout<<"Nilai 4 yang dipilih";
getch();
}
#include <iostream.h>
#include <conio.h>
void main()
{int a;
clrscr();
cout<<"Masukkan nilai antara 1 sampai 4 =";
cin>>a;
if(a==1)
cout<<"Nilai 1 yang dipilih";
else if(a==2)
cout<<"Nilai 2 yang dipilih";
else if(a==3)
cout<<"Nilai 3 yang diplih";
else
cout<<"Nilai 4 yang dipilih";
getch();
}
Kode Jabatan
Latihan 3
#include <iostream.h>
#include <conio.h>
void main()
{int a;
clrscr();
cout<<"Masukkan Kode Jabatan :";
cin>>a;
if(a==1)
{cout<<"Golongan anda 1"<<endl;
cout<<"Gaji anda Rp. 1000000"<<endl;
cout<<"Anda orang miskin";}
else
{cout<<"Golongan anda 2"<<endl;
cout<<"Gaji anda Rp. 200000"<<endl;
cout<<"Anda orang kaya";}
getch();
}
#include <iostream.h>
#include <conio.h>
void main()
{int a;
clrscr();
cout<<"Masukkan Kode Jabatan :";
cin>>a;
if(a==1)
{cout<<"Golongan anda 1"<<endl;
cout<<"Gaji anda Rp. 1000000"<<endl;
cout<<"Anda orang miskin";}
else
{cout<<"Golongan anda 2"<<endl;
cout<<"Gaji anda Rp. 200000"<<endl;
cout<<"Anda orang kaya";}
getch();
}
Menentukan Bilangan Ganjil dan Genap
Welcome gan,, ane mau nunjukin cara menentukan bilangan ganjil dan genap melalui borland C++
Latihan 2
#include<conio.h>
#include<iostream.h>
void main()
{int bil;
clrscr();
cout<<"Masukkan Sebuah Bilangan :";
cin>>bil;
if (bil %2--0)
cout<<"Bilangan Genap"<<endl;
else
cout<<"Bilangan Ganjil"<<endl;
getch();
}
#include<conio.h>
#include<iostream.h>
void main()
{int bil;
clrscr();
cout<<"Masukkan Sebuah Bilangan :";
cin>>bil;
if (bil %2--0)
cout<<"Bilangan Genap"<<endl;
else
cout<<"Bilangan Ganjil"<<endl;
getch();
}
nah gitu caranya gan, bila ada kesalahan mohon komentarnya :) salam
Borland C++
Latihan 1:
#include<iostream.h>
#include<conio.h>
void main ()
{int usia ;
cout <<"berapa usia anda:";
cin >>usia;
if (usia <17)
cout <<"Anda Belum Dewas"<<endl;
else
cout<<"Anda Dewasa"<<endl}
#include<iostream.h>
#include<conio.h>
void main ()
{int usia ;
cout <<"berapa usia anda:";
cin >>usia;
if (usia <17)
cout <<"Anda Belum Dewas"<<endl;
else
cout<<"Anda Dewasa"<<endl}
Langganan:
Postingan (Atom)