Friday, November 30, 2012

Tutorial Pemrograman C++ - Modul 4 OPERATOR (Bagian 2)

Berikut adalah tugas saya, yaitu tutorial Bahasa pemrograman C++ yang membahas tentang modul 4. Pada Modul 4 ini merupakan bahasan lanjutan dari modul 3 yaitu Opreator bagian 1. Pada modul 4 ini yaitu tentang Operator Aritmatika, Operator Logika, Operator Bitwise, dan Operator Ternary.

Berikut adalah Video Tutorialnya :


Source Code Program Operator Aritmatika :

/*Modul 4-1
Operator Aritmatika
Nama : Vidia Handayani
NR   : 49012072 */

# include <iostream>
using namespace std;

int main (void)
{
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;

system ("pause");
return 0;
}


Source Code Program Operator Logika

/* Modul 4-2
Operator Logika
Nama : Vidia Handayani
*/

# include <iostream>
using namespace std;

int main (void)
{

cout << " OPERASI OPERATOR LOGIKA \n";

cout << "\nTabel Kebenaran Operator AND \n";
cout << "1 && 1 = " << (1 && 1) << endl;
cout << "1 && 0 = " << (1 && 0) << endl;

cout << "\nTabel Kebenaran Operator OR \n";
cout << "1 || 1 = " << (1 || 1) << endl;
cout << "1 || 0 = " << (1 || 0) << endl;

cout << "\nTabel Kebenaran Operator NOT \n";
cout << "!1 = " << !1 << endl;
cout << "!0 = " << !0 << endl << "\n";

system ("pause");
return 0;
}

Source Code Program Operator Bitwise :
/*Modul 4-3
Operator Bitwise
Nama : Vidia Handayani
*/

#include <iostream>
using namespace std;

int main (void)
{
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 << "A & B = " << (A & B) << endl;
cout << "A | B = " << (A | B) << endl;
cout << "A ^ B = " << (A ^ B) << endl;

system ("pause");
return 0;
}

Source Code Program Operator Ternary :
/*Modul 4-4
Operator Tenary
Nama : Vidia Handayani
*/

# include <iostream>

using namespace std;

int main (void)
{
int X;
cout << "Masukkan Nilai X = ";
cin >> X;
cout << "\n";

X = (X < 0) ? -X : X;
cout << "| X | = " << X;
cout << "\n \n";

system ("pause");
return 0;
}

Terima kasih atas kunjungannya, semoga bermanfaat :)

No comments:

Post a Comment