Sabtu, 29 September 2012

program piramid

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int f,u,a,d;

cout<<"Masukkan nilai Segitiga :";
cin>>d;
cout<<endl;

for (f=d;f>=0;f--)
{
for(u=f;u>=0;u--)
{
cout<<" ";
}

for(a=0;a<=d-f;a++)
{
cout<<"*";
}
for(a=0;a<d-f;a++)
{
cout<<"*";
}
cout<<endl;
}


    system("pause");
    return 0;
}



Program Kalkulator Sederhana

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
int pilihan;
float a,b,hasil;
cout<<"Ini Adalah Program Kalkulator Sederhana"<<endl;
cout<<"1.Perkalian"<<endl;
cout<<"2.Pembagian"<<endl;
cout<<"3.Penjumlahan"<<endl;
cout<<"4.Pengurangan"<<endl;
cout<<"Pilih Jenis Operasi Penghitungan (1,2,3,4)"<<endl;
cin>>pilihan;
cout<<endl;
cout<<"+++++++++++++++++++++++++++++++"<<endl;
cout<<endl;
cout<<"Masukan Angka Pertama"<<endl;
cin>>a;
cout<<"Masuan Angka Ke Dua"<<endl;
cin>>b;
switch(pilihan)
{
case 1 :{hasil=a*b;cout<<hasil<<endl;}
break;
case 2 :{hasil=a/b;cout<<hasil<<endl;}
break;
case 3 :{hasil=a+b;cout<<hasil<<endl;}
break;
case 4 :{hasil=a-b;cout<<hasil<<endl;}
break;
default : cout<<"Maaf Pilihan Anda Tidak Tersedia :D";
}
system("pause");
return 0;
}