Module 1
-Created program Microsoft Visual Studio 2010,
-Creating program from win32 console application template,
-Input and Output Data,
-Syntax Error
Setelah sebelumnya kita mengenal bahasa C, maka kali ini saya akan menjelaskan tentang bahasa c++. Ya, namanya juga dalam tahap pengenalan, maka kali ini saya akan menjelaskan tentang bagaimana membuat suatu program dengan C++ untuk menampilkan tulisan Hello World.
Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.
1. If statement
An if statement consists of a boolean expression followed by one or more statements. Syntax: if(boolean_expression) { /* statement(s) will execute if the boolean expression is true */ }
2. If else statement
An if statement can be followed by an optional else statement, which executes when the boolean expression is false. Syntax: if(boolean_expression) { /* statement(s) will execute if the boolean expression is true */ } else { /* statement(s) will execute if the boolean expression is false */ }
3. If-else-else-if statement
An if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement.
Syntax: if(boolean_expression 1) { /* Executes when the boolean expression 1 is true */ } else if( boolean_expression 2) { /* Executes when the boolean expression 2 is true */ } else if( boolean_expression 3) { /* Executes when the boolean expression 3 is true */ } else { /* executes when the none of the above condition is true */ }
4. Switch statement
Syntax: switch(expression){ case constant-expression : statement(s); break; /* optional */ case constant-expression : statement(s); break; /* optional */ /* you can have any number of case statements */ default : /* Optional */ statement(s); }
This video below show you examples about if, if-else, if-else-else-if, and switch statement in C++ programming language, which is developed with Microsoft Visual Studio 2010.
In this module there are four types of operators. - Arithmetic Operators - Logical Operators - Bitwise Operators - Ternary Operator
1. Arithmetic Operators
Arithmetic Operators used to perform arithmetic operations of addition, subtraction, multiplication, division and so on. All arithmetic operator applies for integers (integer) and float (float). - (+): adds two operands - (-): subtracts second operand from the first - (*): multiply both operands - (/): divide numerator by de-numerator - (%): modulus Operator and remainder of after an integer division.
2. Logical Operators
Logical operators are used to generate the true value (true) and false (false). This value is known as reconciliation boolean. In C + +, it is usually true value represented by the value 1 and false is represented by 0.
3. Bitwise Operators
There are six types of bitwise operator: - (&): binary AND Operator copies a bit to the result if it exists in both operands. - (|): binary OR Operator copies a bit if it exists in either operand. - (^): binary XOR Operator copies the bit if it is set in one operand but not both. - (~): binary Ones Complement Operator is unary and has the effect of 'flipping' bits. - (<<): binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. - (>>): binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand.
4. Ternary Operator
Ternary Operator an operator that is used in operations involving three operand. The operator is used to declare an operator ?:.
This video below show you examples about arithmetic,logical, bitwise, and ternary operators in C++ programming language, which is developed with Microsoft Visual Studio 2010.
You can also visit this video at www.youtube.com by click this link below.