Pages

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Rabu, 13 April 2011

program menentukan tahun kabisat

#include
#include

using namespace std;
class tahun_kabisat{
friend istream& operator>>(istream&,tahun_kabisat&);
private:
int bil;

public:
void kabisat();
};
istream& operator>>(istream& in,tahun_kabisat& x) {
cout<<"Masukkan tahun="; in>>x.bil;
return in;
}

void tahun_kabisat :: kabisat(){
if(bil % 4 == 0){
cout<<"Tahun kabisat.\n"; } else cout<<"Bukan tahun kabisat.\n"; cout<>X;
X.kabisat();

cout<

system("PAUSE");
return EXIT_SUCCESS;
}

luas dan volum

#include <cstdlib>
#include <iostream>

using namespace std;

class hendy{
      friend istream& operator>>(istream&, hendy&);
      friend ostream& operator<<(ostream&, hendy&);
     
      public:
             hendy();
             void luas_lingkaran(){
                  phi=3.14;
                  luas=phi*r*r;};
             void volume_bola(){
                  phi=3.14;
                  volume=(3*phi*r*r*r)/4;};
            
      private:
              float r;
              float phi;
              float luas;
              float volume;
      };
      hendy::hendy(){
             cout<<"menghitung luas lingkaran dan volume dengan inputan jari - jari\n"<<endl;
             }
            
istream& operator>>(istream& in, hendy& mlebu){
         cout<<"masukkan nilai jari - jari : ";
         in>>mlebu.r;
         return in;
         }
        
ostream& operator<<(ostream& out, hendy& metu){
         out<<"luas lingkaran = "<<metu.luas<<endl;
         out<<"volume bola    = "<<metu.volume<<endl;
         return out;
         }
     

int main(int argc, char *argv[])
{
    usman hendy;
    cin>>hendy;
    hendy.luas_lingkaran();
    hendy.volume_bola();
    cout<<hendy;
   
    system("PAUSE");
    return EXIT_SUCCESS;
}
#include <cstdlib>
#include <iostream>

using namespace std;

class hendy{
      friend istream& operator>>(istream&, hendy&);
      friend ostream& operator<<(ostream&, hendy&);
     
      public:
             hendy();
             void luas_lingkaran(){
                  phi=3.14;
                  luas=phi*r*r;};
             void volume_bola(){
                  phi=3.14;
                  volume=(3*phi*r*r*r)/4;};
            
      private:
              float r;
              float phi;
              float luas;
              float volume;
      };
     
hendy::hendy(){
             cout<<"menghitung luas lingkaran dan volume dengan inputan jari - jari\n"<<endl;
             }
            
istream& operator>>(istream& in, dyas& mlebu){
         cout<<"masukkan nilai jari - jari : ";
         in>>mlebu.r;
         return in;
         }
        
ostream& operator<<(ostream& out, dyas& metu){
         out<<"luas lingkaran = "<<metu.luas<<endl;
         out<<"volume bola    = "<<metu.volume<<endl;
         return out;
         }
     

int main(int argc, char *argv[])
{
    usman hendy;
    cin>>hendy;
    hendy.luas_lingkaran();
    hendy.volume_bola();
    cout<<heru;
   
    system("PAUSE");
    return EXIT_SUCCESS;
}

Program C++ Sederhana Untuk Pencatatan Peminjaman CD

#include <iostream.h>
class CDSys
{
};
int main()
{
char petugas[30];
int balik;
int a,b,c,d,e,f,j,k,l,q,m,i;
char pil;
struct CD
{
int KodeB;
char Judul[30];
int Sewa;
char Stock[30];
}Z[4];
struct daftar
{
int KodeP;
char NamaP[30];
char Status[50];
char Telp[20];
}Y[4];
struct pinjam
{
int KP;
int KB;
int noPinjam;
char tglPinjam[20];
char tglKembali[20];
}X[5];
struct kembali
{
int Lambat;
}W[1];
CDSys baca;
c=0;
e=0;
//ucapan selamat datang
cout<<”UNIVERSITAS KITA BERSAMA”<<endl;
cout<<”Masukkan Nama Anda : “;
cin>>petugas;
cout<<”*——————————————————*”<<endl;
cout<<” Selamat Datang “<<petugas<<” Di CDSys UNIVERSITAS KITA BERSAMA ^^ “<<endl;
cout<<”*——————————————————”<<endl;
//input data CD
cout<<”Masukkan Banyaknya Judul CD : “;
cin>>a;
for (b=0;b<a;b++)
{
cout<<”Kode CD (angka): “;
cin>>Z[b].KodeB;
cout<<”Deskripsi CD : “;
cin>>Z[b].Judul;
cout<<”Kategori CD : “;
cin>>Z[b].Stock;
cout<<endl;
cout<<endl;
}
goto menu;
//menu pilihan
menu:
cout<<”Menu Pilihan”<<endl;
cout<<”1. Daftar CD”<<endl;
cout<<”2. Pendaftaran”<<endl;
cout<<”3. Data Anggota”<<endl;
cout<<”4. Peminjaman”<<endl;
cout<<”5. Pengembalian”<<endl;
cout<<”6. Rekapitulasi”<<endl;
cout<<”7. Keluar”<<endl;
cout<<”Pilihan Anda : “;
cin>>pil;
cout<<endl;
//baca pilihan
if (pil==’1′)
{
goto book;
}
else if (pil==’2′)
{
goto daf;
}
else if (pil==’3′)
{
goto data;
}
else if (pil==’4′)
{
goto pjm;
}
else if (pil==’5′)
{
goto bali;
}
else if (pil==’6′)
{
goto rekap;
}
else if (pil==’7′)
{
cout << endl;
cout << “Terima Kasih ” << petugas << ” Telah Mencoba Sistem Informasi CDSys UNIVERSITAS KITA BERSAMA” << endl;
return 0;
}
else
{
cout<<”Maaf Masukan Anda SALAH”<<endl;
goto menu;
}
//menampilkan daftar CD
book:
for (b=0;b<a;b++)
{
cout<<”Kode CD : “<<Z[b].KodeB<<endl;
cout<<”Deskripsi CD : “<<Z[b].Judul<<endl;
cout<<”Kategori CD : “<<Z[b].Stock<<endl;
cout<<endl;
cout<<endl;
}
goto menu;
//pendaftaran
daf:
for (d=c;d<c+1;d++)
{
cout<<”Kode Peminjam (angka) : “;
cin>>Y[d].KodeP;
cout<<”Nama Peminjam : “;
cin>>Y[d].NamaP;
cout<<”Status : “;
cin>>Y[d].Status;
cout<<”Nomor Telephone : “;
cin>>Y[d].Telp;
cout<<endl;
cout<<endl;
}
c=c+1;
k=c;
goto menu;
//data Anggota
data:
for (d=0;d<c;d++)
{
cout<<”Kode Peminjam (angka) : “<<Y[d].KodeP<<endl;
cout<<”Nama Peminjam : “<<Y[d].NamaP<<endl;
cout<<”Status Peminjam : “<<Y[d].Status<<endl;
cout<<endl;
cout<<endl;
}
goto menu;
//peminjaman
pjm:
for (f=e;f<e+1;f++)
{
cout<<”Nomor Peminjaman:”;
cin>>X[f].noPinjam;
cout<<”Kode Peminjam (angka) : “;
cin>>X[f].KP;
for (d=0;d<c-1;d++)
{
if (Y[d].KodeP==X[f].KP)
{
cout<<”Nama Peminjam : “<<Y[d].NamaP<<endl;
}
else
{
cout<<”Data Tidak Ditemukan”<<endl;
cout<<endl;
goto pjm;
}
}
cout<<”Kode CD (angka) : “;
cin>>X[f].KB;
for (b=0;b<a;b++)
{
if (Z[b].KodeB==X[f].KB)
{
cout<<”Judul CD : “<<Z[b].Judul<<endl;
}
else
{
cout<<”Data Tidak Ditemukan”<<endl;
cout<<endl;
goto pjm;
}
}
cout<<”Tanggal Pinjam : “;
cin>>X[f].tglPinjam;
cout<<”Tanggal Kembali : “;
cin>>X[f].tglKembali;
cout<<endl;
cout<<endl;
}
e=e+1;
goto menu;
//pengembalian
bali:
cout<<”Masukkan Kode Peminjam : “;
cin>>balik;
for (f=0;f<e;f++)
{
if (X[f].KP == balik)
{
cout<<”Kode CD : “<<X[f].KB<<endl;
cout<<”Tanggal Pinjam : “<<X[f].tglPinjam<<endl;
cout<<”Tanggal Kembali : “<<X[f].tglKembali<<endl;
}
else
{
cout<<”Masukan Anda SALAH”<<endl;
goto bali;
}
}
cout<<endl;
cout<<endl;
goto menu;
//rekapitulasi
rekap:
cout<<”Nama Petugas “<<petugas<<endl;
cout<<”Rekapitulasi CDSys UNIVERSITAS KITA BERSAMA”<<endl;
cout<<endl;
for (j=0;j<e;j++)
{
cout<<”Kode Peminjam : “<<X[j].noPinjam<<endl;
cout<<”Kode Peminjam : “<<X[j].KP<<endl;
for (l=0;l<k;l++)
{
if (Y[l].KodeP==X[j].KP)
{
cout<<”Nama Peminjam : “<<Y[l].NamaP<<endl;
}
}
cout<<”Kode CD : “<<X[j].KB<<endl;
for (b=0;b<a;b++)
{
if (Z[b].KodeB==X[j].KB)
{
cout<<”Judul CD : “<<Z[b].Judul<<endl;
}
}
cout<<”Tanggal Pinjam : “<<X[j].tglPinjam<<endl;
cout<<”Tanggal Kembali : “<<X[j].tglKembali<<endl;
cout<<endl;
}
goto menu;
}

Program C + +: Creating a Simple Calendar

Algorithm: we fed the year and month codes [1 ... 12]
if the year is a leap year (the year runs out at the 4 or 400 and not go on for 100), and code-month = 2 (February), then there is 29 days if not then there is 28 days
if code in there 31 days 1,3,5,7,8,10,12
if the code months 4, 6.9 then there is 30 days
if not months of code between the number [1 ... 12), then one month code
# Include <iostream> # Include <conio.h>
int main () { int year, month, bil;
court <<"enter the year:"; cin>> year; court <<"Enter month [1 ... 12]:"; cin>> month;
switch (month) { case 2: if ((year% 100 == 0) | | (year% 100! = 0) & & (year% 400 == 0)) { for (int i = 1; i <= 29; i + +) { court <<i <<""; } } else { for (int i = 1; i <= 28; i + +) { court <<i <<""; } } break; case 1: case 3: case 5: case 7: case 8: case 10: case 12: { for (int i = 1; i <= 31; i + +) { court <<i <<""; } } break;
case 4: case 6: case 9: { for (int i = 1; i <= 30; i + +) { court <<i <<""; } } break; default: court <<"wrong code in \ n"; } getch ();

Contoh Pernyataan For Sederhana Dalam Program C++ (Sample Statement For Simplified In C + + Program)

# include <iostream>
02 # include <conio.h>
03
04 void main ()
05 {
06 clrscr ();
07 int i;
08 for (i = 0; i <10; i + +)
09 {
10 court <<"C ++"<< endl;
11}
12 getch ();
13}

Simplified Explanation of Statement For Program C + + In the above:

First we create a new variable i of type integer. In a statement for, i was given the initial value is 0. Then do the test if i <10, because the result is true the statements inside the For executed. Then do the increment of i in the statement i + +. Then performed the test again if i <10. If yes (true) then in the For statement is executed, if not then the program continues into the bottom of For. And so on until the test i <10 is false.

Program C++ Mencari Nilai Rata-Rata Dengan For(Program C + + Finding Value With Average For)

As we know that in the programming language C + + For statement is used for looping (looping) of one or a number of statements. As an example we can find the average value of the input by the user. Then the program will display the total number and average value of the value entered by the user. Suppose we want to find the average value of 10 values ​​entered by the user, then the C + + program is as follows: 01 # include 02 # include 03 04 void main () 05 { 06 float n, total, rata2; 07 total = 0; 08 for (int i = 0; i <10; i + +) 09 { 10 court <<"Enter the value to" <<(i +1) <> n; 12 total = total + n; 13} 14 rata2 = total / 10; 15 court <<"Total =" <<total <<endl; 16 court <<"rata2 =" <<rata2 <<endl; 17 getch (); 18} Explanation of Program C + + Finding With Average Value For: At first we declare variables, namely n, total and rata2 with type float. Why float? so that later the average value which can be displayed in the form of fractions. Total variable we will use to store our total value of the initialization (give the initial value) with 0. Furthermore we do looping (looping) with For as much as 10 times starting from 0 to 9. In each iteration we ask for input from the user to be stored in the variable n. Then the total value (new) added value of n which had previously been entered by the user. After 10 times iteration (looping), we find the average value by doing the division of total variable is the total divided by 10 and the results are stored in a variable rata2. The final step is to display the total value stored in the variable total and displays the average value stored in the variable average.

Senin, 04 April 2011

coding kalkulator 2

#include<stdio.h>
#include<conio.h>
void menu();
void jumlah();
void kurang();
void kali();
void bagi();
void main()
{
char chrPilihan;
do
{
menu();
fflush(stdin);
scanf(“%c”,chrPilihan);
if ((chrPilihan == ‘x’)||(chrPilihan == ‘x’))
{ printf(“Thanks for use this program… egie_ku@yahoo.com”);
break;}
switch (chrPilihan)
{ case ‘1′:
jumlah();
break;
case ‘2′:
kurang();
break;
case ‘3′:
kali();
break;
case ‘4′:
bagi();
break;
default:
printf(“nSorry bro.. Kode yang di imput salah…n”);
}
}
while(chrPilihan != ‘x’);
}
void menu()
{
printf(” n”);
printf(“Main Menun”);
printf(“==================n”);
printf(“1. Operasi Penjumlahann”);
printf(“2. Operasi Pengurangann”);
printf(“3. Operasi Perkaliann”);
printf(“4. Operasi Pembagiann”);
printf(“x. Untuk Keluarn”);
printf(” n”);
printf(“Input kode masukkan,bro!!: “);
}
void jumlah()
{
int jumlah,bil1,bil2;
printf(“Bilangan 1 nya apa?? “);
scanf(“%d”,bil1);
printf(“Bilangan kedua?? “);
scanf(“%d”,bil2);
jumlah=bil1+bil2;
printf(“Hasilnya tambahannya %dn”,jumlah);
printf(“nPencet Enter buat lanjut..n”);
getch();
}
void kurang()
{
int jumlah,bil1,bil2;
printf(“Bilangan 1 nya apa?? “);
scanf(“%d”,bil1);
printf(“Bilangan kedua?? “);
scanf(“%d”,bil2);
jumlah=bil1-bil2;
printf(“Hasilnya kurangannya %dn”,jumlah);
printf(“nPencet Enter buat lanjut..n”);
getch();
}
void kali()
{
int jumlah,bil1,bil2;
printf(“Bilangan 1 nya apa?? “);
scanf(“%d”,bil1);
printf(“Bilangan kedua?? “);
scanf(“%d”,bil2);
jumlah=bil1*bil2;
printf(“Hasilnya kalinya %dn”,jumlah);
printf(“nPencet Enter buat lanjut..n”);
getch();
}
void bagi()
{
int jumlah,bil1,bil2;
printf(“Bilangan 1 nya apa?? “);
scanf(“%d”,bil1);
printf(“Bilangan kedua?? “);
scanf(“%d”,bil2);
jumlah=bil1/bil2;
printf(“Hasilnya baginya %dn”,jumlah);
printf(“nPencet Enter buat lanjut..n”);
getch();
}