Operator Betwise C++

Operator Betwise Berguna untuk operasi bit pada pemrograman c++.

Berikut adalah video tutorial pemrograman c++ menggunakan operator betwise.

Dan berikut adalah Source code yang digunakan dalam video tersebut.

/*Modul 4-3
Operator Bitwise.cpp
Nama : Wayan Widya Artana
NRP  : 49013035
*/

#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 <<“1 << 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, B; A = 1; 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;
}


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s