=================================================*
Program membuat menu
=================================================*
#include<iostream.h>
int main ()
{
int pilihan;
cout <<”*********Menu Favorit Anda*********”<<endl;
cout <<”1. Huruf vokal dan konsonan” <<endl;
cout <<”2. Menentukan Karakter” <<endl;
cout <<”\n”;
cout <<”Masukan Pilihan Anda [1..2]:”;
cin >>pilihan;
switch (pilihan)
{
case 1 :
{
char huruf;
cout <<”1. Huruf vokal dan konsonan” <<endl;
cout <<”Masukan sebuah huruf:”;
cin >>huruf;
if ((huruf == ‘A’) || (huruf == ‘a’) || (huruf ==’I') || (huruf == ‘i’) ||
(huruf == ‘U’) || (huruf == ‘u’) || (huruf == ‘E’) || (huruf == ‘e’) ||
(huruf == ‘O’) || (huruf == ‘o’))
{
cout << huruf <<”adalah huruf vokal”;
}
break;
}
case 2:
{
char karakter;
cout <<”2. Menentukan Karakter” <<endl;
cout <<”Masukan Sebuah Karakter:”;
cin >> karakter;
if (karakter >=’A’ && karakter <=’Z')
cout<<”Masukan Anda Adalah Huruf Besar”;
else if (karakter >=’a’ && karakter <=’z')
cout<<”Masukan Anda adalah huruf kecil”;
else if (karakter >=’0′ && karakter <=’9′)
cout<<”Masukan Anda adalah angka”;
else
cout<<”Masukan Anda bukan Alphanumeric”;
break;
}
default:
cout<<”Kode yang Anda masukan Salah, cobalah beberapa tahun lagi!!!!”<<endl;
break;
}
return 0;
}
==============================================*
Menghitung bilangan Faktorial
==============================================*
#include <iostream.h>
int main()
{
int BIL, C;
long faktorial=1;
cout<<”Masukkan bilangan yang akan dihitung=”;
cin>>BIL;
C=BIL;
cout<<C<<”!=”;
while (C>=1)
{
faktorial*=C;
if (C!=1){
cout<<C<<”X”;
}else {
cout<<C<<”=”;
}
cout<<faktorial;
return 0;
}
}
===================================================*
Program menghasilkan segitiga pascal
===================================================*
#include <iomanip.h>
#include <conio.h>
#include <iostream.h>
main()
{
unsigned int n,a,b,x,s[100],p[100];
cout<<”Masukkan nilai n: “; cin>>n;
for(a=0,x=0;a<=n;a++,x+=2)
{
cout<<setw(3*n-x);
s[a]=1;
p[a]=1;
for(b=0;b<=a;b++)
{
if (b<1||b==a) cout<<”1″<<setw(4);
else
{
s[b]=p[b];
p[b]=s[b-1]+s[b];
cout<<p[b]<<setw(4);
}
}
cout<<endl;
}
getch();
return 0;
}
=====================================================================*
Menghitung nilai desimal ke biner
=====================================================================*
#include <iostream.h>
#include <conio.h>
#include <math.h>
void main()
{
int p,n,i=0;
cout<<”Masukkan bilangan desimal : “;
cin>>p;
double A[100];
do
{
A[++i]=p%2;
p=p/2;
floor(p);
} while (p>1);
cout<<”Nilai binernya : “;
cout<<p;
for(n=i;n>=1;n–)
{
cout<<A[n];
}
getch();
}
============================================================*
Looping
============================================================*
#include <iostream.h>
void main()
{
int n;
for(;;)
{
cout<<”Masukkan bilangan integer : “; cin>>n;
if(n % 2 == 0) continue;
else if(n % 5 == 0) break;
cout<<”\tLanjutkan loop berikutnya.\n”;
}
cout<<”Akhiri Loop.\n”;
}
============================================================*
Bilangan Matriks
============================================================*
#include<iostream.h>
#include<iomanip.h>
int main()
{
int x,y;
for (x=1; x<=5; x++)
{
for (y=1; y<=5; y++)
{
cout<<setw(4)<<x+y<<”";
}
cout<<”\n”;
}
return 0;
}
==============================================================*
- Follow us on Twitter, or subscribe to the rizqtech RSS Feed for more daily web development and articles.
Enjoy this Post!


May 2nd, 2010 at 11:46 pm
hi brilliant little site you got here
I employ the identical web theme on mine although for whatever nutty cause it appears to reload a lot quicker on this blog although this blog includes more content. Are you using different plugins or widgets which quicken it up? If you could share the names so maybe I might use them in my personal internet sites so twilight breaking dawn fans could watch twilight eclipse online trailers and clips easier I would be grateful – cheers in advance