BAB I


1. Buatlah program yang menampilkan biodata pribadi anda.



#include <iostream>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
 char n[20],a [50],ttl[20],c[20],h[50];

 cout<<"\t\t\t\tSelamat Datang Di Program Input Biodata\n\n"<<endl;
  cout<<"Nama       : ";
 cin>>n;
  cout<<"Alamat     : ";
 cin>>a;
  cout<<"TTL        : ";
 cin>>ttl;
  cout<<"Hobi       : ";
 cin>>h;
  cout<<"Cita-cita  : ";
 cin>>c;

 cout<<"\n\n\t\t Biodata Diri \n";
 cout<<"Nama :"<<n<<"\nAlamat :"<<a
 <<"\nTTL  : "<<ttl
 <<"\nHobi"<<h<<"\nCita-cita  :"<<c<<endl;

 return 0;
}



3. buatlah program yang menampilkan huruf I yang semuanya menggunakan karakter ‘*’ dengan tinggi 6 karakter dan lebar 3 karakter


#include <iostream>

using namespace std;
int main(int argc, char** argv){
char i[]="***\n***\n***\n***\n***\n***\n\n";
cout<<i;
return 0;
}


4. buatlah program untuk menghitung luas dan keliling lingkaran beserta volume bola. Buat deklarasi terpisah antara variabel dan konstanta yang diperlukan



#include <iostream>
#include <windows.h>


/* run this program using the console pauser or add your own getch, system("pause") or input loop */

using namespace std;


int main(int argc, char** argv) {
   int pil;
   int r;
   float L;
   float kel;
   float vol;
   char back;

 do{

  cout<<" Masukkan Pilihan Anda"<<endl;
   cout<<"\t1. Luas Lingkaran."<<endl;
   cout<<"\t2. Keliling Lingkaran."<<endl;
   cout<<"\t3. Volume Bola.\n"<<endl;
   cout<<"Masukkan Pilihan : ";
   cin>>pil;

   switch(pil){
 case 1 :
   cout<<" Anda akan menghitung luas lingkaran."<<endl;
   cout<<" Masukkan jari-jarinya : ";
   cin>>r;
   L=3.14*r*r;
   cout<<" Luas lingkaran adalah : "<<L;
   break;

  case 2 :
   cout<<" Anda akan menghitung keliling lingkaran."<<endl;
   cout<<" Masukkan jari-jarinya : ";
   cin>>r;
   kel=3.14*2*r*r;
   cout<<" Keliling lingkaran adalah : "<<kel;
    break;
  
   case 3 :
   cout<<" Anda akan menghitung volume bola."<<endl;
   cout<<" Masukkan jari-jari : ";
   cin>>r;
   vol=0.75*3.14*r*r*r;
   cout<<" Volume bola adalah : "<<vol;
   break;
  
   Default :
    cout<<"Not Responding";
    cout<<endl;
  }
   cout<<"\n\nApakah ingin memilih menu lagi (y atau n) : ";
 cin>>back;
 system("CLS");}
 while(back=='y');
    return EXIT_SUCCESS;
}




 5. buatlah program yang menampilkan pilihan-pilihan menu dari sebuah restoran atau cafe.



.#include <iostream>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
 int pil;
 cout<<"Pilihan Menu Cafe Expresso : \n";
 cout<<"\t1. Menu Makanan\n";
 cout<<"\t2. Menu Minuman\n";
 cout<<"Masukkan Pilihan : ";cin>>pil;
 switch(pil){
  case 1 :
   cout<<" Makanan : \n";
   cout<<"1. Nasi Goreng \n";
   cout<<"2. Mie Goreng/Rebus\n";
   cout<<"3. Tempura\n";
   cout<<"4. Kentang Goreng\n";
   cout<<"5. Roti Baka\n";
    break;
  case 2 :
   cout<<" Minuman : \n";
   cout<<"1. Juice Jeruk\n";
   cout<<"2. Juice Alpukat\n";
     cout<<"3. Juice Apel\n";
     cout<<"4. Juice Tomat\n";
   cout<<"5. Milkshake Vanila/Coklat\n";
    break;
 }
 return 0;
}



 6. Buatlah program yang merepsentasikan cerita berikut. Ibu memberi uang kepada adik sebesar 20 ribu rupiah. Ibu meminta adik untuk membeli 3 kg beras. Setiap kilogram beras harganya Rp 5.500.- Berapakah uang kembalian yang diterima adik ?

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{int x,y,z;
x=20000;y=5500;
z=x-(3*y);
cout<<"UANG DARI IBU : Rp."<<x<<"\n";
cout<<"ADEK MEMBELI 3 Kg BERAS DENGAN HARGA Rp."<<y<<" per Kg \n";
cout<<"UANG KEMBALIAN : Rp.";

cout<<z<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}



7.Ulangi untuk kasus no 6. Apabila banyak beras tidak diketahui, berapa kg maksimal beras yang dapat dibeli ?

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
int x,y,z;
x=20000;y=5500;
z=x/y;
cout<<"UANG DARI IBU : Rp.20.000\n";
cout<<"ADEK MEMBELI BERAS DENGAN HARGA Rp.5.500 per Kg\n";
cout<<"Kg BERAS YANG DAPAT DI BELI : ";

cout<<z<<" Kg"<<endl;

    system("PAUSE");
    return EXIT_SUCCESS;
}



8. Buatlah sekurang-kurangnya 4 baris puisi (boleh potongan lagu), kemudian buat program yang menampilkan per baris. Untuk menampilkan baris berikutnya, user diminta menekan sebuah tombol.



#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
cout<<"kau adalah yang terindah\n";
system("PAUSE");
cout<<"\n\nyang membuat hatiku tenang \n";
system("PAUSE");
cout<<"\n\nkucintai kamu takkan pernah tau\n";
system("PAUSE");
cout<<"\n\nsegalah kekurangan ku\n";

    system("PAUSE");
    return EXIT_SUCCESS;
}











Previous
Next Post »
Copyright © 2015 Bettong'rs All Right Reserved
Created by Arlina Design Powered by Blogger