Wednesday, October 26, 2022

Algoritma dan Struktur Data Pertemuan 6

 Assalamualaikum wr.wb                                                                                                                                                                                                                 


Nama: Muhamad Syarif Ramadhan
Nim  : 3420227001
Prodi: Teknik Informatika

Contoh 1

                                                      Lampiran Contoh 1 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>


void main()
{
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001

int a;
   for (a=1;a<=10;a++){
    cout<<"Ini adalah baris ke -"<<a<<endl;
   }
   getch();
}

Contoh 2

                                                                            Lampiran Contoh 2 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main(){
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001

puts("=========================");
   puts("  Program For Bersarang  ");
   puts("=========================");
   int a,b;
   for (a=1;a<=2;a++){
    for (b=1;b<=2;b++){
      printf("Latihan Algoritma\n");
      }
   }
   getch();
}

Contoh 3


                                                            Lampiran Contoh 3 sofware Borland C++

#include <iostream.h>
#include <stdio.h>
#include <conio.h>

void main(){
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001

int a,b;
   for(a=1;a<=8;a++){
    printf("\n");
      for(b=a;b<=8;b++){

      printf("%d",a);
   }
 }
 getch();
}

Contoh 4


                                                            Lampiran Contoh  4 sofware Borland C++

#include <iostream.h>
#include <stdio.h>
#include <conio.h>

void main(){
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001

int a,b;
   char lagi;
atas:
clrscr();
   cout<<"Masukan Bilangan =";cin>>a;
   b=a%2;
   printf("Nilai %d %%2 adalah=%d",a,b);
   printf("\n\n Ingin Hitung Lagi [Y/T]:");
   lagi=getche();
   if(lagi=='Y'|| lagi=='y'){goto atas;}
   getch();
}

Contoh 5


                                                            Lampiran Contoh  5 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main ()
{
//Nama : Muhamad Syarif Ramadhan
//NIM : 3420227001

    int bil = 1;
    while (bil<=10)
    {
    printf (" %d ",bil);
      bil++;
    }
    bil = 2;
    cout<<endl;
    do
    {
    printf (" %d ",bil);
      bil+=2;
    } while (bil <=10);
   getch();
}

Contoh 6


                                                            Lampiran Contoh  6 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main ()
{
//Nama : Muhamad Syarif Ramadhan
//NIM  : 3420227001

int bil = 2;
   int b=0;
   do
   {
    if (bil <20) { printf (" %d +",bil); }
else {printf (" %d = ",bil); }
      b = b + bil;
      bil = bil + 2;
    }
   while (bil<=20);
   cout<<b;
   getch();
}

Contoh 7


                                                            Lampiran Contoh  7 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main ()
{
//Nama : Muhamad Syarif Ramadhan
//NIM  : 3420227001

    int a,b,c;
    for (a=2;a<=10;a+=2)
    {
    b=2; c=0;
    do
    {
      c = c + b;
         if (a == b) {cout<<b<<" = "<<c;} else {cout<<b<<" + ";}
         b = b + 2;
}
while (b<=a);
cout<<endl;
}
getch();
}

Contoh 8


                                                            Lampiran Contoh  8 sofware Borland C++


#include <stdio.h>
#include <conio.h>
#include <iostream.h>


void main ()
{
//Nama : Muhamad Syarif Ramadhan
//NIM  : 3420227001

    int a,b,c;
    for (a=1;a<=9;a+=2)
    {
    b=1; c=1;
      do
      {
      c = c * b;
         if (a == b) {cout<<b<<" = "<<c;} else {cout<<b<<" * ";}
         b = b + 2;
  }
  while (b<=a);
  cout<<endl;
  }
  getch();
}
                                                 Sekian dan Terimakasih
                                             Wassalamualaikum wr.wb

Friday, October 14, 2022

Algoritma dan Struktur Data Pertemuan 5

 Assalamualaikum wr.wb                                                                                                                                                                                                                 


Nama: Muhamad Syarif Ramadhan
Nim  : 3420227001
Prodi: Teknik Informatika

Contoh 1


                                                            Lampiran Contoh 1 sofware Borland C++

include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main(){

//Nama : Muhamad Syarif Ramadhan
//Nim  : 3420227001

char kode,lagi;

atas:
clrscr();
   cout<<"Masukan Kode Menu Makanan [A/B/C]";
   kode =getche();
   cout<<'\n';
   switch (kode){
    case'A':case 'a':
      cout<<"Ayam Bakar"; break;
      case'B':case 'b':
      cout<<"Nasi Goreng"; break;
      case'C':case 'c':
      cout<<"Soto Betawi"; break;
      default:
      cout<<"Anda Salah Masukan Kode";
   }
   cout<<'\n';
   cout<<"\nIngin Pilih Lagi [Y/T]:";
   lagi=getche();
   if(lagi=='Y'||lagi=='y')goto atas;
   getch();
}

Contoh 2

                                                                            Lampiran Contoh 2 sofware Borland C++

#include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main(){
//Nama : Muhamad Syarif Ramadhan
//Nim  : 3420227001

   char kode,lagi; char menu[50],bonus[50];
   int jml; float harga,total,pot,ppn,grand;
lagi:
clrscr();
   printf("Masukan Menu Makanan[1/2/3]:");cin>>kode;
   printf("Jumlah Pembelian Makanan   :");cin>>jml;
   switch(kode){
    case '1':
      strcpy(menu,"Combo Fire Chicken");harga=35000;
         break;
      case '2':
      strcpy(menu,"Combo Fire Wings");harga=33000;
         break;
      default:
      strcpy(menu,"Combo Duo Fire Chicken");harga=50000;
   }
   total=harga*jml;ppn=0.1*total;

   if(jml>5){
    strcpy(bonus,"Tumbler");
      pot=0.1*total;
   } else {
    strcpy(bonus,"Maaf Tidak Dapat Bonus");
      pot=0;
   }
   grand=total+ppn-pot;
   clrscr();
   puts("           RICHEESE FACTORY");
   puts("         Jl.Pekayon Raya No.106");
   puts("====================================");
   cout<<"Menu Makanan  :"<<menu<<endl;
   cout<<"Harga Menu    :"<<harga<<endl;
   cout<<"Bonus         :"<<bonus<<endl;
   cout<<"Total Bayar   :"<<total<<endl;
   cout<<"Potongan      :"<<pot<<endl;
   cout<<"PPN           :"<<ppn<<endl;
   cout<<"Grand Total   :"<<grand<<endl;
   puts("=====================================");
   puts("           Terima Kasih");
   cout<<"        Ingin Pesan Lagi.?";cin>>lagi;
   if (lagi== 'Y' || lagi=='y'){goto lagi;}
   getch();

}

Contoh 3


                                                            Lampiran Contoh 3 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main(){
//Nama : Muhamad Syarif Ramadhan
//Nim  : 3420227001

char nama[30],tipe[30],souvenir[20];
   char kode,lagi;
   int lama;
   float harga,total,admin=150000,ubay,ukem;

awal:

clrscr();
   puts("HOTEL BINTANG LIMA");
   puts("===================================");
   cout<<"Nama Penyewa        :";cin>>nama;
   cout<<"Kode Kamar [S/T/D]  :";cin>>kode;

   if (kode=='S' || kode=='s')
   {
    strcpy(tipe,"Single Room");
      harga=200000;
   }
   else if (kode=='T' || kode=='t')
   {
      strcpy(tipe,"Twim Room");
      harga=300000;
   }
   else if (kode=='D' || kode=='d')
   {
    strcpy(tipe,"Double Room");
      harga=450000;
   }
   else
   {
    puts("============================");
      cout<<"Kode Kamar Yang Anda Masukan Salah, Silahkan Input lagi";
      cin>>lagi;
      switch(lagi)
      {
      case'Y':
         case'y':
          goto awal;
         default:
          goto akhir;
      }
   }

   clrscr();
   puts("HOTEL BINTANG LIMA");
   puts("============================");
   cout<<"Nama Penyewa      :"<<nama<<endl;
   cout<<"Kode Kamar [S/T/D]:"<<kode<<endl;
   cout<<"Lama Menginap     :";cin>>lama;
   puts("============================");

   if(lama>=7)
   {
    strcpy(souvenir,"Tas Ransel");
   }
   else
   {
    strcpy(souvenir,"Tidak Dapat");
   }
   total=(harga*lama)+ admin;
   cout<<"Tipe Kamar \t\t:" <<tipe<<endl;
   cout<<"Lama Menginap \t\t:"<<lama<<"hari"<<endl;
   cout<<"Souvenir \t\t:"<<souvenir<<endl;
   printf("Biaya Sewa \t\t: Rp.%8.2f\n",harga);
   printf("Biaya Administrasi \t: Rp.%8.2f\n",admin);
   printf("Total Biaya Sewa \t: Rp.%8.2f\n",total);
   puts("==============================");
   cout<<"Uang Bayar :";cin>>ubay;
   ukem=ubay-total;
   cout<<"Uang Kembali:"<<ukem<<endl;
   cout<<"Ingin Input lagi [Y/T]";cin>>lagi;
   switch(lagi)
   {
    case'Y':
      case'y':
      goto awal;
      default:
      goto akhir;
   }

akhir:
getch();
}

                                                Sekian dan Terimakasih
                                             Wassalamualaikum wr.wb

Sunday, October 2, 2022

Algoritma dan Struktur Data Pertemuan 4

  Assalamualaikum wr.wb                                                                                                                                                                                                                 


Nama: Muhamad Syarif Ramadhan
Nim  : 3420227001
Prodi: Teknik Informatika

Contoh 1


                                                            Lampiran Contoh 1 sofware Borland C++

#include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main() {
//Nama : Muhamad Syarif Ramadhan
//Nim : 3420227001

int absen,tugas,uts,uas;
   float total;
   puts("Program Menghitung Nilai Mahasiswa");
   puts("++++++++++++++++++++++++++++++++++");
   printf("Masukan Nilai Absen:");scanf("%d",&absen);
   printf("Masukan Nilai Tugas:");scanf("%d",&tugas);
   printf("Masukan Nilai UTS:");scanf("%i",&uts);
   printf("Masukan NIlai UAS:");scanf("%I",&uas);
total=(absen*0.1)+(tugas*0.2)+(uts*0.3)+(uas*0.4);
   puts("++++++++++++++++++++++++++++++++++");
   printf("Total Adalah:%.2f(Bentuk Tidak Terformat)\n",total);
   printf("Total Adalah:%.2f(Bentuk Yang Terhormat)\n",total);
   puts("++++++++++++++++++++++++++++++++++");
   if (total>=75)
   {cout<<"Selamat Kamu Lulus.";}
   else
   {cout<<"Maaf Kamu Tidak Lulus.";}
   getch();
   }

Contoh 2

                                                                            Lampiran Contoh 2 sofware Borland C++




#include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main(){

// Nama : Muhamad Syarif Ramadhan
// Nim  : 3420227001


      int pilih;
      char huruf [20];
      printf ("Silakan Pilih Program [1/2]:") ; cin >> pilih;
      if (pilih == 1){
      clrscr();
                        puts ("+++++++++++++++++++++++++");
                        puts ("\Contoh Program Strlen");
                        puts ("+++++++++++++++++++++++++");
                        cout <<"Masukan Sembarang Kata = "; gets (huruf);
                        cout <<"Panjang Kata Yang Diinput = "<<strlen(huruf);
      getch() ;
      }
      else if (pilih == 2){
      clrscr();
puts ("+++++++++++++++++++++++++");
puts ("\Contoh Program Strcmp");
puts ("+++++++++++++++++++++++++");
char a1 [] = "Z";
char a2 [] = "z";
char b1 [] = "Z";
cout <<"Hasil Perbandingan "<<a1<<" dan "<<a2<< "->";
cout <<strcmp (a1,a2) <<endl;
cout <<"Hasil Perbandingan "<<a2<<" dan "<<a1<< "->";
cout <<strcmp (a2,a1) <<endl;
cout <<"Hasil Perbandingan "<<a1<<" dan "<<b1<< "->";
cout <<strcmp (a1,b1) <<endl;
getch();
    }
}

Contoh 3


                                                            Lampiran Contoh 3 sofware Borland C++

#include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main(){

// Nama : Muhamad Syarif Ramadhan
// Nim  : 3420227001

char gol,jab[10];
long gapok;
   cout<<endl<<"Data Jabatan"<<endl
<<"++++++++++++++++++++++++++"<<endl;
cout<<"Masukan Golongan [1/2]: ";cin>>gol;
if(gol=='1'){
strcpy(jab,"Manajer");
gapok=6000000;
}
else if(gol=='2'){
strcpy(jab,"Karyawan");
gapok=4500000;
}
else{
printf("Golongan %c tidak terdaftar.\n",gol);
strcpy(jab,"None");
gapok=0;
}
cout<<"Jabatan = "<<jab<<endl;
cout<<"Gaji Pokok = "<<gapok<<endl;
getch();
   }

Contoh 4


                                                            Lampiran Contoh 4 sofware Borland C++
#include <stdio.h>
#include <iostream.h>
#include <conio.h>

void main(){

// Nama : Muhamad Syarif Ramadhan
// Nim  : 3420227001

char kode,ukuran,merk[15]="None";
long harga=0;
cout<<"Kode Baju [1/2] : ";cin>>kode;
cout<<"Ukuran [S/M] : ";cin>>ukuran;
if (kode=='1'){
    strcpy(merk, "Converse");
if (ukuran=='S' || ukuran == 's') {harga=200000;} else {harga=210000;}
}
else if (kode=='2'){
strcpy(merk,"Nike");
//Bentuk penulisan if versi singkat
if (ukuran=='S' || ukuran == 's') harga=600000; else harga=610000;
   }
else{
cout<<"Salah Kode Baju"<<endl;
}
cout<<"Merk Baju :"<<merk<<endl;
cout<<"Harga Baju :"<<harga<<endl;
getch();
}
                                                  
                                                  Sekian dan Terimakasih
                                             Wassalamualaikum wr.wb

Thursday, September 22, 2022

Algoritma Dan Struktur Data Pertemuan 3

 Assalamualaikum wr.wb                                                                                                                                                                                                                 


Nama: Muhamad Syarif Ramadhan
Nim  : 3420227001
Prodi: Teknik Informatika

Contoh 1


                                                            Lampiran Contoh 1 sofware Borland C++


#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main()
{
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001

int x,y;
int a,b,c,d;
clrscr();
cout<<"Masukan Nilai X: "; cin>>x;
cout<<"Masukan Nilai Y: "; scanf("%d",&y);
/*Left Value    Operator Right Value*/
/*===================================================*/
            a = x+y;
c = x%y;
b = x-y;
d = x*y;
         /*===================================================*/

        cout<<endl<<endl;
printf("Hasil dari A = X+Y= %i \n",a);
printf("Hasil dari B = X-Y= %i \n",b);
cout<<"Hasil dari C = X%Y= "<<c<<endl;
cout<<"Hasil dari D = X*Y= "<<d<<endl;
getch();
}

Contoh 2

                                                        Lampiran Contoh 2 sofware Borland C++


#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main()
{
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001

int a,b;
clrscr();
/*Penggunaan Notasi di depan Variable*/
        a=2; b=14;
printf("Nilai A \t\t= %d",a); printf("\nNilai ++A \t\t= %d",++a);
        printf("\nNilai B \t\t= %d",b); printf("\nNilai --B \t\t= %d",--b);
cout<<endl<<endl;
/*Penggunaan Notasi di belakang Variable*/
        a=22; b=1414;
printf("Nilai A \t\t= %d",a); printf("\nNilai A++ \t\t= %d",a++);
        printf("\nNilai A \t\t= %d",a); printf("\nNilai B \t\t= %d",b);
        printf("\nNilai B-- \t\t= %d",b--); printf("\nNilai B \t\t= %d",b);
getch();
}

Contoh 3


                                                            Lampiran Contoh 3 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main()
{
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001

    float a, b, c, d, e, f, x, y;
    clrscr();
   cout<<"Masukan Nilai X = "; cin>>x;
   cout<<"Masukan Nilai Y = "; cin>>y;

   /* Bernilai sama dengan */
   a =     x==y;
   /*         Bernilai sama dengan */
   b =             x!=y;
   /* Bernilai sama dengan */
   c =                                                   x>y;
   /* Bernilai sama dengan */
   d =                                                   x<y;
   /* Bernilai sama dengan */
   e =                                                   x>=y;
   /* Bernilai sama dengan */
   f =                                                   x<=y;

   cout<<endl;
   cout<<"Hasil dari"<<x<<"=="<<y<<" = "<<a<<endl;
   cout<<"Hasil dari"<<x<<"!="<<y<<" = "<<b<<endl;
   cout<<"Hasil dari"<<x<<">"<<y<<" = "<<c<<endl;
   cout<<"Hasil dari"<<x<<"<"<<y<<" = "<<d<<endl;
   cout<<"Hasil dari"<<x<<">="<<y<<" = "<<e<<endl;
   cout<<"Hasil dari"<<x<<"<="<<y<<" = "<<f<<endl;
getch();
}

Contoh 4

                                                            Lampiran Contoh 4 sofware Borland C++

#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main()
{
//Nama : Muhamad Syarif Ramadhan
//Nim : 3420227001

   puts("=============================");
   puts("Contoh Penggunaan Fungsi Gets");
   puts("=============================");

   char nama[28];
   /*
    Fungsi gets () digunakan untuk memasukkan data bertipe karakter dan
      tidak dapat digunakan untuk memasukkan data numerik.
   */
   printf("Masukkan Nama Anda: ");gets(nama);
   printf("Nama Anda Adalah: %s \n",nama);
getch() ;
}

                                                 Sekian dan Terimakasih
                                             Wassalamualaikum wr.wb

Wednesday, September 14, 2022

Algoritma Dan Struktur Data Pertemuan 2

                                                Assalamualaikum wr.wb                                                                                                                                                                                                                 

Nama: Muhamad Syarif Ramadhan
Nim  : 3420227001
Prodi: Teknik Informatika

Contoh 1


                                                    Lampiran Contoh 1 sofware Borland C++


#include <iostream.h>
#include <conio.h>

void main(){
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001
cout<<"Ini Adalah Program C++ Pertama Saya"<<endl;
cout<<"Nama:Muhamad Syarif Ramadhan"<<endl;
cout<<"Nim :3420227001";
getch();
}

                                         Lampiran Keterangan Contoh 1 sofware Borland C++


   Fungsi-fungsi pustaka yang umum digunakan untuk menampilkan hasil yang
   prototype-nya berada di file judul iostream.h
   1. cout()
       Fungsi cout() merupakan sebuah objek didalem Borland C++
       digunakan untuk menampilkan suatu data kelayar.
   2. endl
       endl merupakan suatu fungsi manipulator yang digunakan
       untuk menyisipkan karakter NevLine atau mengatur pindah baris.
   3. getch()
       Fungsi getch() (get characher and echo) dipakaiuntuk membaca
       sebuah karakter dan karakter yang dimasukan tidak akan
      di layar.


Contoh 2


                                                 Lampiran Contoh 2 sofware Borland C++

#include <iostream.h>
#include <conio.h>
#include <stdio.h>

void main(){
//Nama: Muhamad Syarif Ramadhan
//Nim : 3420227001
const float phi = 3.14;
int jari = 7;
float luas;
printf("Nilai dari jari-jari adalah %d \n",jari);
luas = jari * jari * phi;
printf("Luas lingkaran adalah %.3f",luas);
getch();
}


                                           Lampiran Keterangan Contoh 2 sofware Borland C++


Fungsi-fungsi pustaka yang umum digunakan untuk menampilkan hasil yang
prototype-nya berada di file judul iostream.h
   1. printf()
    Merupakan fungsi keluaran yang paling umum digunakan untuk
        menampilkan informasi kelayar.
   2. getch()
       Fungsi getch() (get characher and echo) dipakaiuntuk membaca
       sebuah karakter dan karakter yang dimasukan tidak akan
       di layar.

                                                Sekian dan Terimakasih
                                             Wassalamualaikum wr.wb

Friday, November 24, 2017