Nama : Deab Sina
NIM : 49012078
Jurusan : D4 TMD ITB Batch 6
This is video about: Arithmetic Operator, Logical Operator, Bitwise Operator.
Link to this video:
Source Code:
// Video source code
#include<iostream>
using namespace std;
int main()
{
// Arithmetic Operator
int a, b, c, d, e;
a = 1+1; // Addition
b = 1-1; // Substration
c = 1*1; // Multiplicatiion
d = 1/1; // Division
e = 1%1; // Modulo
cout<<"======================================="<<endl;
cout<<" Arithmetic Operator:"<<endl;
cout<<"======================================="<<endl;
cout<<"1 + 1 = "<<a<<endl;
cout<<"1 - 1 = "<<b<<endl;
cout<<"1 * 1 = "<<c<<endl;
cout<<"1 / 1 = "<<d<<endl;
cout<<"1 % 1 = "<<e<<endl;
cout<<"======================================="<<endl;
cout<<" Logical Operator:"<<endl;
cout<<"======================================="<<endl;
cout<<"1&&1 = "<<(1&&1)<<endl; // AND operator
cout<<"1||1 = "<<(1||1)<<endl; // OR operator
cout<<"!1 = "<<!1<<endl; // NOT operator
cout<<"======================================="<<endl;
cout<<" Bitwise Operator:"<<endl;
cout<<"======================================="<<endl;
cout<<"1 & 0 = "<<(1&0)<<endl; // AND
cout<<"1 | 0 = "<<(1|0)<<endl; // OR
cout<<"1 ^ 1 = "<<(1^1)<<endl; // XOR
cout<<"!1 = "<<!1<<endl; // NOT ! the same ~
cout<<"5 <<1 = "<<(5<<1)<<endl; // Shift Left
cout<<"10>>1 = "<<(10>>1)<<endl; // Shift Right
system("pause");
return 0;
}
#include<iostream>
using namespace std;
int main()
{
// Arithmetic Operator
int a, b, c, d, e;
a = 1+1; // Addition
b = 1-1; // Substration
c = 1*1; // Multiplicatiion
d = 1/1; // Division
e = 1%1; // Modulo
cout<<"======================================="<<endl;
cout<<" Arithmetic Operator:"<<endl;
cout<<"======================================="<<endl;
cout<<"1 + 1 = "<<a<<endl;
cout<<"1 - 1 = "<<b<<endl;
cout<<"1 * 1 = "<<c<<endl;
cout<<"1 / 1 = "<<d<<endl;
cout<<"1 % 1 = "<<e<<endl;
cout<<"======================================="<<endl;
cout<<" Logical Operator:"<<endl;
cout<<"======================================="<<endl;
cout<<"1&&1 = "<<(1&&1)<<endl; // AND operator
cout<<"1||1 = "<<(1||1)<<endl; // OR operator
cout<<"!1 = "<<!1<<endl; // NOT operator
cout<<"======================================="<<endl;
cout<<" Bitwise Operator:"<<endl;
cout<<"======================================="<<endl;
cout<<"1 & 0 = "<<(1&0)<<endl; // AND
cout<<"1 | 0 = "<<(1|0)<<endl; // OR
cout<<"1 ^ 1 = "<<(1^1)<<endl; // XOR
cout<<"!1 = "<<!1<<endl; // NOT ! the same ~
cout<<"5 <<1 = "<<(5<<1)<<endl; // Shift Left
cout<<"10>>1 = "<<(10>>1)<<endl; // Shift Right
system("pause");
return 0;
}