readbud - get paid to read and rate articles

Pemrograman C++ Function

/*
Program UTS Praktikum Pemrograman I
Nama File : UTS.c
Nama : Wanda
*/

#include
#include
#include
#include
using namespace std;

#define pass 1234
#define i 24

int pil;//variabel global
int x,password;//password
int y,ayam;//kasus anak ayam
int a,b,jml_genap;//Jumlah genap
int baris,kolom,jml,bil;

void menu(int pil)
{
textcolor(LIGHTGREEN);
gotoxy(i,7);cout<<" ================================ ";
textcolor(YELLOW);
gotoxy(i,8);cout<<"| Menu |";
textcolor(LIGHTGREEN);
gotoxy(i,9);cout<<" ================================ ";
textcolor(YELLOW);
gotoxy(i,10);cout<<"| 1. Kasus anak ayam |";
gotoxy(i,11);cout<<"| 2. Jumlah bilangan genap |";
gotoxy(i,12);cout<<"| 3. Tampilan angka segitiga |";
gotoxy(i,13);cout<<"| 4. Keluar |";
textcolor(LIGHTGREEN);
gotoxy(i,14);cout<<" ================================ ";
textcolor(YELLOW);
gotoxy(i,15);cout<<"| Masukkan pilihan [1..4] : |";
textcolor(LIGHTGREEN);
gotoxy(i,16);cout<<" ================================ ";
textcolor(LIGHTCYAN);
gotoxy(52,15);cin>>pil;
system("cls");
}

void anak_ayam(int ayam)
{
textcolor(YELLOW);
if(pil==1)
cout<<"Masukkan jumlah anak ayam: ";cin>>ayam;
cout< textcolor(LIGHTCYAN);
for(y=ayam;y>=2;y--)
{
cout<<"Anak ayam turun "< }
cout<<"Anak ayam turun 1, mati satu tinggal induknya"<}

void bil_genap(int b)
{
if(pil==2)
cout<<"Masukkan batas bilangan : ";cin>>b;
textcolor(LIGHTCYAN);
cout<<"\nJumlah bilangan genap = ";
for(a=1;a<=b;a++)
{
if(a%2==0)
{
cout< jml_genap=jml_genap+a;
if(a cout<<" + ";
}
}
cout< cout<<" = "<}

void angka_segitiga(int jml)
{
if(pil==3)
{
cout<<"Masukkan banyak baris : ";cin>>jml;
cout< textcolor(LIGHTCYAN);
for(baris=1;baris<=jml;baris++)
{
for(kolom=1;kolom<=baris;kolom++)
{
cout< bil++;
}
cout< }
for(baris=jml-1;baris>=1;baris--)
{
for(kolom=1;kolom<=baris;kolom++)
{
cout< bil++;
}
cout< }
cout< }
}

char *kode()
{
do
{
gotoxy(19,11);textcolor(YELLOW);
cout<<"Masukkan password (kesempatan ke-"<>password;
if(password==pass)
{
cout<<"Password Anda Benar";
}
else
{
cout<<"Password Anda Salah";
}
x++;
}while((password!=pass)&&(x!=4));
}


int main(int argc, char *argv[])

{
//warna Latar
textbackground(GREEN);
system("cls");

//inisialisasi
x=1;//password
//proses

gotoxy(19,12);kode();
getch();
system("cls");
do
{
//inisialisasi
jml_genap=0;//jumlah genap dan ganjil
bil=1;//bilangan segitiga

menu(pil);//menu

if(pil==1)
{
anak_ayam(ayam);//anak ayam
}
else
if(pil==2)
{
bil_genap(b);//bilangan genap
}
else
if(pil==3)
{
angka_segitiga(jml);//anak segitiga
}
else
if(pil==4)
{
textcolor(LIGHTCYAN);
cout<<"Terima kasih sudah menggunakan program ini!"< }
else
{
textcolor(LIGHTCYAN);
cout<<"Anda salah pilih!"< }
textcolor(WHITE);
system("PAUSE");
system("cls");
}while(pil!=4);



system("PAUSE");
return EXIT_SUCCESS;
}

Tidak ada komentar:

Posting Komentar