• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Tugas praktikukm  pemrograman c++
 

Tugas praktikukm pemrograman c++

on

  • 510 views

 

Statistics

Views

Total Views
510
Views on SlideShare
510
Embed Views
0

Actions

Likes
0
Downloads
50
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Tugas praktikukm  pemrograman c++ Tugas praktikukm pemrograman c++ Document Transcript

    • TUGAS PRAKTIKUKM MICROSOFT VISUAL STUDIO PEMROGRAMAN C++ DENDI RIADI : TEKNIK KOMPUTER KARYAWAN SEMESTER 4 /* ========================================================= Program Pertama microsoft visual studio 2010 Modul 1 Nama : Dendi Riadi =========================================================*/ #include <iostream> //preprosesor int main() // fungsi main { std::cout << "Ini adalah pertama sayan"; std::cout << "Dengan menggunakan Microsoft Visual Studio C++.n"; return 0; } // modul 2.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> int _tmain(int argc, _TCHAR* argv[]) { std::cout << "ini program kedua saya n"; std::cout << "Menggunakan visual C++." << std::endl; return 0; } //modul 1-3 #include <iostream> using namespace std; int main() { char tampilkan[1]; char panjang_data[50]; cout << "================================================ n"; cout << " BELAJAR PEMROGRAMAN C++ n"; cout << "================================================ n"; cout << " NAMA : "; cin.getline (panjang_data,50); cout << " JURUSAN : Teknik Komputer POLITEKNIK PAJAJARAN " <<endl; cin.getline(tampilkan,1); return (0); } /* Modul 1.4 Belajar Syntax error ======================================= */ #include <iostream> using namespace std; int main()
    • { cout << "+++++++++++++++++++++++++++++++++++++++++++ n"; cout << " Memepelajari Syntax errorr n"; cout << "+++++++++++++++++++++++++++++++++++++++++++ n"; cout << " Syntax error adalah kesalahan n"; cout << " Jangan lupa untuk melakukan perintah n"; cout << " Clean Solution yang berada pada n"; cout << " menu Build, sebelum mengkompilasi n"; cout << " program Microsoft Visual Studio C++ n"; return (0); } // modul 1-5 // limit.cpp #include <iostream> #include <limits> using namespace std; int main() { cout << " TIPE DATA n"; cout << "===============================n"; cout << " minimum char = " << CHAR_MIN << endl; cout << " maximum char = " << CHAR_MAX << endl; cout << " minimum signed char = " << SCHAR_MIN << endl; cout << " maximum signed char = " << SCHAR_MAX << endl; cout << " maximum unsigned char = " << UCHAR_MAX << endl; cout << " minimum short = " << SHRT_MIN << endl; cout << " maximum short = " << SHRT_MAX << endl; cout << " minimum int = " << INT_MIN << endl; cout << " maximum int = " << INT_MAX << endl; cout << " minimum long = " << LONG_MIN << endl; cout << " maximum long = " << LONG_MAX << endl; cout << " maximum unsigned short="<<USHRT_MAX<<endl; cout << " maximum unsigned = " << UINT_MAX << endl; cout << " maximum unsigned long ="<<ULONG_MAX<<endl; return (0); } // Modul 2-1 // Tipe data dasar.cpp #include <iostream> using namespace std; int main() { cout << "============================================== n"; cout << " BELAJAR TIPE DATA n"; cout << "============================================== n"; int X; X = 10; cout << "Contoh Nilai Tipe Bilangan Bulat X = " << X << endl << endl; double Y; Y =123.123; cout << "Contoh Nilai Tipe Bilangan Riil Y = " << Y << endl << endl; char Karakter = 'A';
    • char* Teks = "Kata"; char TEKS[39] = "Teks dengan batas sebanyak 39 karakter"; cout << Karakter << endl; cout << Teks << endl; cout << TEKS << endl << endl; return (0); } //Modul 2-2 //Konversi type data #include <iostream> using namespace std; int main() { char Karakter = 'D'; cout << "Karakter D = " << Karakter << endl; cout << "Nilai ASCII = " << (int) Karakter << endl; return (0); } // Modul 2-3 // Konstanta #include <iostream> using namespace std; const int MAX = 10; int main() { int A[MAX]; for (int C = 0; C < MAX; C++) { A[C] = C * 7; } for (int c = 0; c < MAX; c++) { cout << A [c] << endl; } return (0); } // modul 2-4 // variabel global & lokal #include <iostream> using namespace std; int A; int main() { A = 10;
    • cout << " Nilai variabel A = " << A << endl << endl; int B; B = 300; cout << " Nilai Variabel B = " << B << endl << endl; return (0); } //Modul 3-1 //Operator Assignment #include <iostream> using namespace std; int main() { int a,b; a = 20; b = 100; a = b; b = 7; cout << "a = "; cout << a; cout << endl; cout << "b = "; cout << b; cout << endl; return (0); } // modul 3-2 // operator unary #include <iostream> using namespace std; int main() { int e,g; double f,h; e = +8; f = -3.14; cout << "Nilai e : " << e << endl; cout << "Nilai f : " << f << endl; g = -e; h = -f; cout << "Nilai g : " << g << endl; cout << "Nilai h : " << h << endl; return (0);
    • } // modul 3-3 // increment #include <iostream> using namespace std; int main() { int i,j; i = 5; cout << "Nilai i awal : " << i << endl; cout << "Nilai ++i : " << ++i << endl; cout << "Nilai i akhir : " << i << endl; cout << 'n'; j = 10; cout << "Nilai j awal : " << j << endl; cout << "Nilai ++j : " << ++j << endl; cout << "Nilai j akhir : " << j << endl; cout << 'n'; return (0); } // modul 3-4 // decrement #include <iostream> using namespace std; int main() { int k; float l; k = 100; l = 10.5; cout << "Nilai k awal : " << k << endl; cout << "Nilai --k : " << --k << endl; cout << "Nilai k akhir : " << k << endl; cout << 'n'; cout << "Nilai l awal : " << l << endl; cout << "Nilai l-- : " << l-- << endl; cout << "Nilai l akhir : " << l << endl; return (0); } //modul 4-1 //operator aritmatika #include <iostream> using namespace std;
    • int main() { cout << "2 + 3 = " << 2 + 3 << endl << endl; cout << "10 - 5 = " << 10 - 5 << endl << endl; cout << "4 x 3 = " << 4 * 3 << endl << endl; cout << "4 / 2 = " << 4 / 2 << endl << endl; cout << "10 % 3 = " << 10 % 3 << endl << endl; return (0); } // modul 4-2.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { std::cout << " OPERASI OPERATOR LOGIKA n"; cout << "n Tabel Kebenaran operator AND n"; cout << " 1 && 1 = " << (1 && 1) << endl; cout << " 1 && 0 = " << (1 && 0) << endl; cout << " 0 && 1 = " << (0 && 1) << endl; cout << " 0 && 0 = " << (0 && 0) << endl; cout << "n Tabel Kebenaran operator OR n"; cout << " 1 || 1 = " << (1 || 1) << endl; cout << " 1 || 0 = " << (1 || 0) << endl; cout << " 0 || 1 = " << (0 || 1) << endl; cout << " 0 || 0 = " << (0 || 0) << endl; cout << "n Tabel Kebenaran operator NOT n"; cout << " !1 = " << !1 << endl; cout << " !0 = " << !0 << endl << "n"; return (0); } // Modul 4-3 // Operator Bitwise #include <iostream> using namespace std; int main() { int U, V, W; U = 1 << 1;
    • V = 1 << 2; W = 1 << 3; cout << "1 << 1 = " << U << endl; cout << "1 << 2 = " << V << endl; cout << "2 << 3 = " << W << endl << endl; int X, Y, Z; X = 16 >> 1; Y = 16 >> 2; Z = 16 >> 3; cout << "16 >> 1 = " << X << endl; cout << "16 >> 2 = " << Y << endl; cout << "16 >> 3 = " << Z << endl << endl; int A = 1; int B = 0; cout << "A = " << A << endl; cout << "B = " << B << endl; cout << "!A = " << !A << endl; cout << "!B = " << !B << endl; cout << "A & B = " << (A & B) << endl; cout << "A | B = " << (A | B) << endl; cout << "A ^ B = " << (A ^ B) << endl << endl; return 0; } // modul 4-4.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int X; cout << "Masukkan Nilai X = "; cin >> X; cout << 'n'; X = (X < 0) ? -X : X; cout << "|X| = " << X; cout << "n n"; return 0; } //project 5-1 : Pencabangan IF // Nama : Dendi #include <iostream> #include <string> using namespace std; int main() { cout << "Kelulusan Siswa n n"; double Nilai_Ujian; cout << "Masukkan Nilai Ujian : ";
    • cin >> Nilai_Ujian; cout << endl; char Hasil_Ujian[12] = "Tidak Lulus"; if (Nilai_Ujian >= 60) strcpy (Hasil_Ujian, "Lulus"); cout << "Hasil Ujian : " << Hasil_Ujian << endl << endl; return (0); } // Project 5-2 : Pencabangan Dua Kondisi (IF_ELSE) // Nama : Dendi Riadi #include <iostream> using namespace std; int main() { cout << "KELULUSAN SISWA n n "; double Nilai_Ujian; cout << "Msukkan Nilai Ujian : "; cin >> Nilai_Ujian; cout << endl; if (Nilai_Ujian >= 60) { cout << ("Hasil Ujian = LULUS") << endl << endl; } else { cout << "Hasil Ujian = TIDAK LULUS" << endl << endl; } return (0); } //modul 5-3 : pencabangan IF bersarang // Nama : Dendi Riadi #include <iostream> using namespace std; int main() { double Nilai_Ujian; char Indeks; cout << " KONVERSI NILAI SISWA n n"; cout << " Masukkan Nilai Ujian : "; cin >> Nilai_Ujian; cout << endl; if (Nilai_Ujian >= 85){ Indeks = 'A';} else
    • if (Nilai_Ujian >= 75){ Indeks = 'B';} else if (Nilai_Ujian >= 55){ Indeks = 'C';} else if (Nilai_Ujian >= 40){ Indeks = 'D';} else { Indeks = 'E';} cout << "Indeks Siswa = " << Indeks << endl; return (0); } // Project 5-4 : Pernyataan Switch // Nama : Dendi Riadi #include <iostream> using namespace std; int main () { int pilihan; cout << "Staff pengajar pemrograman C++ :" << endl; cout << "================================" << endl; cout << "1. Dr. Ary Setijadi Prihatmanto" << endl; cout << "2. Dr. Aciek Ida Wuryandarin"; cout << "3. Dr. Pranoto Rusmin"; cout << "n4. Hendrayana, MT" << endl; cout << "5. Marisa Paryasto, MT" << endl; cout << "6. Kusprasapta Mutijarsa, MT" << endl; cout << "7. Syahban Rangkuti, MT" << endl; cout << "8. Reza Darmakusuma, MT" << endl; cout << "9. Ferlin Ashadi, MTn"; cout << "10.Amiratusyadiah, MT" << endl << endl; cout << "Staff pengajar Pemrograman C++ : "; cin >> pilihan; cout << endl; switch (pilihan) { case 1: cout << "Pilihan anda salahn" << endl; break; case 2: cout << "Pilihan anda benarn" << endl; break; case 3: cout << "Pilihan anda salahn" << endl; break; case 4: cout << "Pilihan anda salahn" << endl; break; case 5: cout << "Pilihan anda benarn" << endl; break; case 6: cout << "Pilihan anda salahn" << endl; break; case 7:
    • cout << "Pilihan anda benarn" << endl; break; case 8: cout << "Pilihan anda benarn" << endl; break; case 9: cout << "Pilihan anda salahn" << endl; break; case 10: cout << "Pilihan anda benarn" << endl; break; default: cout << "Pilihan anda tidak ada dalam daftarnn"; } return (0); } // Modul 6-1 // Nama : Dendi Riadi #include <iostream> using namespace std; int main() { int pencacah = 1; do { cout << " D4 - Teknologi Media Digital n" ; pencacah++ ; } while (pencacah <= 10); return (0); } // modul 6-2.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int pencacah = 1; do { cout << " TEKNIK KOMPUTER & MULTIMEDIA n" << endl; cout << " POLITEKNIK PAJAJARAN n" << endl << endl; pencacah++ ; } while (pencacah <=6); return 0; } // modul 6-3.cpp : Defines the entry point for the console application. // #include "stdafx.h"
    • #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { cout << "PENGULANGAN MENAIK" << endl; for (int C=0; C<10; C++){ cout << C+1 << endl; } cout << 'n'; cout << "PENGULANGAN MENURUN " << endl; for (int D=10; D>0; D--){ cout << D << endl; } return 0; } // modul 6-4.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { for (int j=1; j<=10; j++){ for (int k=1; k<=j; k++){ cout << k*j << ' '; } cout << 'n'; } return 0; }