Kamis, 18 Oktober 2012

C++


1. Menentukan Rumus

#include <iostream.h>

#include <stdio.h>

void main()
{
float pilihan,s,r,t,VK,LL,VS;

cout<<"1. Menghitung Volume Kubus "<<endl;
cout<<"2. Menghitung

Luas Lingkaran "<<endl;
cout<<"3. Menghitung Volume Silinder "<<endl;
cout<<"\n";
cout<<"Pilih rumus ke- berapa yang ingin anda pilih? ";
cin>>pilihan;

cout<<"\n";
if(pilihan==1)
{
cout<<"VOLUME KUBUS"<<endl;
cout<<"berapa sisi-nya? ";
cin>>s;
VK=s*s*s;
cout<<"+++++++++++++++++++++++++++"<<endl;
cout<<"Rumus Volume Kubus = s*s*s "<<endl;
cout<<"+++++++++++++++++++++++++++"<<endl;
cout<<"diketahui : "<<endl;
cout<<"sisi kubus (s) = "<<s<<endl;
cout<<"+++++++++++++++++++"<<endl;
cout<<"JAWAB : "<<endl;
cout<<"V="<<s;
cout<<"*"<<s;
cout<<"*"<<s;
cout<<"="<<VK<<endl;
cout<<"+++++++++++++"<<endl;
cout<<"volume kubus-nya adalah "<<VK<<endl;
}
if(pilihan==2)
{
cout<<"[LUAS LINGKARAN]"<<endl;
cout<<"berapa jari-jari (r) lingkaran-nya? ";
cin>>r;
LL=3.14*r*r;
cout<<"==============================="<<endl;
cout<<"Rumus Luas Lingkaran = 3.14*r*r"<<endl;
cout<<"==============================="<<endl;
cout<<"diketahui : "<<endl;
cout<<"phi = 3.14 "<<endl;
cout<<"jari-jari (r) = "<<r<<endl;
cout<<"================="<<endl;
cout<<"JAWAB : "<<endl;
cout<<"Luas = 3.14";
cout<<"*"<<r;
cout<<"*"<<r;
cout<<"="<<LL<<endl;
cout<<"============="<<endl;

cout<<"\nluas lingkaran-nya adalah "<<LL<<endl;
}
if(pilihan==3)
{
cout<<"[VOLUME SILINDER]"<<endl;
cout<<"berapa jari-jari (r) silinder-nya? ";
cin>>r;
cout<<"berapa tinggi (t) silinder-nya? ";
cin>>t;
VS=3.14*r*r*t;
cout<<"=================================="<<endl;
cout<<"Rumus Volume Silinder = 3.14*r*r*t"<<endl;
cout<<"=================================="<<endl;
cout<<"diketahui : "<<endl;
cout<<"phi = 3.14 "<<endl;
cout<<"jari-jari (r) = "<<r<<endl;
cout<<"tinggi (t) = "<<t<<endl;
cout<<"============="<<endl;
cout<<"JAWAB : "<<endl;
cout<<"V = 3.14";
cout<<"*"<<r;
cout<<"*"<<r;
cout<<"*"<<t;
cout<<"="<<VS<<endl;
cout<<"============="<<endl;

cout<<"\nvolume silinder-nya adalah  "<<VS<<endl;
}
else
{
cout<<"maaf rumus tidak tersedia";
}
getch();
}

Screenshot :



2. Menampilkan Z sampai A

#include <iostream>
using namespace std;

int main()
{ char abjad;
for ( abjad ='Z'; abjad >= 'A';abjad--)
{
cout <<abjad <<" ";
}
return 0;
}

Screenshot :

3. Mentukan Tahun Kabisat atau Bukan

#include <iostream>
using namespace std;
int main()
{
int tahun,awal,akhir;
cout<<"Masukkan Tahun Awal : "; cin>>awal;
cout<<"Masukkan Tahun Akhir : "; cin>>akhir;
cout <<endl;

for(tahun=awal; tahun<=akhir; tahun++) {
if (tahun%4==0)
{
cout <<"Tahun Kabisat : " <<tahun <<endl;
cout <<endl;
}
else {
cout <<"Bukan Tahun Kabisat : " <<tahun <<endl;
cout <<endl;
}

}
}

Screenshot :




Tidak ada komentar:

Posting Komentar