Program c++ if else

February 5, 2011

#include <iostream.h>

void main()
{
int umur;
cout << “berapakah umur anda : “;
cin >> umur;
if (umur > 17)
cout << “anda boleh masuk”;
else
cout << “anda tidak boleh masuk”;
}

Advertisements

Program c++ tidak habis dibagi 5

February 5, 2011

#include <iostream.h>

void main ()

{
int bil;
for (bil=1 ; bil<=25 ; bil++)
{
if (bil %5!= 0)
cout << bil <<” “;
}
//cout << “\n”;
}


Program c++ tebak-tebakan

February 5, 2011

#include<iostream.h>
void main()
{
int angka,tebak;
angka=1011;
cout << “masukan tebakan anda:”;
cin >> tebak;
while (angka!=tebak) // for (;angka!=tebak;)
{
if (angka<tebak)
cout << “angka terlalu besar:”;
else
cout << “angka terlalu kecil:”;
cout << endl;
cout << “tebak lagi:”;
cin >> tebak;
}
cout << “anda benar hadiah spesial buat kamu:”;
}


Program c++ menghitung pangkat(n)

February 5, 2011

#include<iostream.h>
int pangkat(int x,int n);
void main()
{
int x,y;
cout<<“menghitung x^y”<<endl;
cout<<“x=”;
cin>>x;
cout<<“y=”;
cin>>y;
cout<<x<<“^”<<y<<“=”<<pangkat(x,y);
}
int pangkat(int x,int n)
{
if(n==1)
return x;
else
return x * pangkat (x,n-1);
}


Program c++ menghitung bilangan kuadrat

February 5, 2011

#include<iostream.h>
int kuadrat(int x);
void main()
{
int angka;
cout<<“masukkan angka:”;
cin>>angka;
cout<<angka<<“kuadrat adalah”;
cout<<kuadrat(angka);
}
int kuadrat(int x)
{
return(x*x);
}


Program c++ bilangan genap

February 5, 2011

#include<iostream.h>
void main()
{
int i;
for(i=1;i<25;i++)
{
if(i % 2==0)
cout<<i<<endl;
}
}


XOR-Encryption

July 27, 2010

Exclusive-OR encryption, while not a public-key system such as RSA, is almost unbreakable through brute force methods. It is susceptible to patterns, but this weakness can be avoided through first compressing the file (so as to remove patterns). Exclusive-or encryption requires that both encryptor and decryptor have access to the encryption key, but the encryption algorithm, while extremely simple, is nearly unbreakable.

Read the rest of this entry »