Kamis, 09 Februari 2012

Operators in Language C/C++ Part 3

On this entry we will continue the discussion about the operator, which we have discussed previously on Arithmetic Operators, Increment and decrement operators, and Operator Relations (Comparative).
At this post, we will discuss and Logical Operators Bitwise Operators.


1. Logical operators
Logical operators are used to connect two or more expressions into a conditional expression.


<> Sample Program Logical operators


<> Output Program Logical operators


2. Bitwise operators
Bitwise operators are used to manipulate data in the form of bit.


>> Bitwise operator << (Shift Left)
Bitwise Left Shift Operator << is used to shift a bit to the left
Example: 0001 0101 = 21 if the shift left 1 bit 0010 1 010 = 42

<> Sample Program Operator Bitwise << (Shift Left)


<> Output Program Operator Bitwise << (Shift Left)


>> Operators Bitwise >> (Shift Right)
Bitwise Shift Right operator >> is used to shift a bit to the right
Example: 0001 0010 = 18 if it is shifted to the right 2 bits 0000 0100 = 4

<> Sample Program Operator Bitwise >> (Shift Right)


<> Output Program Operator Bitwise >> (Shift Right)


>> Bitwise operators & (AND)
Bitwise operators & (AND) is used to compare the bits of two operands. Will be true (1) if all the operands are combined is true (1).

<> Sample Program Operator Bitwise & (AND)



<> Output Program Operator Bitwise & (AND)



>> Bitwise Operators | (OR)
Bitwise Operators | (OR) was used to compare the bits of two operands. Bernilain be true if either operand is combined there is a value true (1).

<> Sample Program Operator Bitwise | (OR)


<> Output Program Operator Bitwise | (OR)


>> Bitwise operators ^ (XOR)
Bitwise operators ^ (XOR) is used to compare the bits of two operands. Bernilain be true (1) if there is one two-bit operand is compared to only a true value (1).

<> Sample Program Operator Bitwise ^ (XOR)


<> Output Program Operator Bitwise ^ (XOR)


So, only that material Operator Discussion About On Programming Language C / C + +. Good luck to try.

Operators in Language C/C++ Part 2

On entry this time, I will continue the subject in the previous post operator, In previous posts we've talked about arithmetic operators, and now we will discuss about the Increment and decrement operators, and Operator Relations (Comparative).

A. Increment and decrement operators.
>> In C + + programming, providing an addition and decrement operators (Increment & decrement).


>> A = A + 1 or A = A - 1; can be simplified to  A + = 1 or  A - = 1 and can be simplified to A++ or A--, the notation ++ or --  can be put in front of or behind the variable.
Example: A-- or --A and A++ or ++A These two forms of writing above has a different meaning:
  • If placed in front of the variable. Then the addition or subtraction will be done just before or immediately at the time of encounter, leaving the variable value change once was going to direct this expression is encountered.
  • If placed on the back of the variables. Then the addition or subtraction will be performed after this look at the encounter or the value of the variable will be fixed when the expression is found.
<> Examples of Use of Notation Increment Program (enhancer) and decrement (reduction) in Front of variables.


<> Use of Notation Output Increment Program (enhancer) and decrement (reduction) in Front of variables.

<> Examples of Use of Notation Increment Program (enhancer) and decrement (reduction) in the Rear Variable

<> Use of Notation Output Increment Program (enhancer) and decrement (reduction) in the Rear Variable.


2. Operation Relations (Comparative).
The operator of this relation is used to compare two values. The results of the comparison operator is a numeric value 1 (True) or 0 (False).

<> Example Program Relations (Comparative)

<> Output Relations Program (Comparison)


Senin, 06 Februari 2012

Operators in Language C/C++ Part 1

The operator is a symbol or character used to be involved in the program to do operation or manipulation.
Example: Addition, subtraction, division and others.

The operator has the properties:
A. unary
Unary properties of the operator only involves an operand in an arithmetic operation. Example: -5
2. binary
Binary properties the operator involves two operands in an arithmetic operation. Example: 4 + 8
3. ternary
Tenary operator properties involve three operands in an arithmetic operation. Example: (10% 3) + 4 + 2

Type of Operator:
A. Arithmetic operators:
Operators for arithmetic operations are classified as binary:


Arithmetic operators are divided into 2 (two):
>> Assignment operator.
Assignment operator in C + + language of the equal sign ("=").
Example: value = 80; A = x * y;

explanation:

variable "value" is filled with 80 and
variable "A" is filled with the results of multiplication between x and y.

Example Program:
<> Script Program 1



<> Output Program 1



<> Script Program 2


<> Output Program 2



>>Hierarchy of Arithmetic Operators
In a akspresi arotmatika can we find some different arithmetic operators simultaneously. Arithmetic operator sequence is as follows:



example:
A = 8 2 * 3/6
Step calculation:
A = 8 6/6 in which 6/6 = 1
A = 8 1
A = 9

This operator is negligible levels by the use of parentheses (and)

example:
A = (8 2) * 3/6
Step calculation:
A = 10 * 3/6 where 8 2 = 10
A = 30/6
A = 5

Example Program:
<> Script Program 1


<> Output Program 1


 <> Script Program 2


<> Output Program 2


So first, posting about it OPERATOR. We continued again in the upcoming posts, so still learning with it. Thanks for those who have visited, please more frequent visits.

Sabtu, 04 Februari 2012

Identify the Components of the Program

This time we will learn to identify and recognize the structure / component in a program, as well as identify errors that occur in programs that we make.

in the previous post we have studied the structure or component in a program, namely:
1. Identifier (variables, constants, data types and functions).
2. Data types (int, float, char, etc.).
3. Variable Declaration.
4. Assignment / Grading
5. constants
6. comment

Now we will create a more simple program in which there are several components, not all the components we enter, we will only use the header, variables, data types, assignment, and comments. We will also determine which part is called the header, variables, data types, assignment, and comments.

Program that we will create is the program to calculate the area of triangles, which we will give titles Count Area of a Triangle.

Script Program :



In the script above we can see what is contained therein, the explanation is written on his comments. Now we will execute the program and see the output generated by sciprt program we have created.

Output Program (compiler : borland C++) :

 

that is the output that will be generated by the program. Next we will identify a program that there are some errors in it. we will use the same program as above. but we will correct what is wrong section, and not in accordance with the above script program.

Script Program :


errors that occur after the compilation:



Identification of Errors that occur in program :
1. Header :  
#include (conio.h) should be #include <conio.h>

2. Deklarasi variabel :
int base, height, area. should be int base, height, area;

3. Masukan / Input :
scanf("%d",base); and scanf("%d",height) should be scanf("%d",&base); and scanf("%d",&height);

4. Keluaran /Output :
printf("\nLuas Segitiga = %d", &area); should be printf("\nLuas Segitiga = %d", area);

So that I can convey in this post, may can be helpful in learning the programming language C / C + +.

Jumat, 03 Februari 2012

Basics of Programming Languages ​​C / C + +

This time we will learn about the basics of programming languages C / C + +.
 
In the programming language C / C + + there are several components that we need to know in advance, and we learn, that is:
 
1. IDENTIFIER / IDENTITY
Identifier is a name commonly used in programming to declare variables, constants, data type, and function. Rules for writing the identifier, among other:
•    Can not start with non-letter characters
•    There should be no spaces
•    Should not use these characters ~! @ # $% ^ & * () + '- = {} []: ";' <>?,. / |
•    Should not use reserved words that exist in C / C + +.

2. DATA TYPES
There are some types of data we need to know, below are the various types of data.


3. DECLARATION OF VARIABLES
Just as Pascal, variables used in the program must be declared first. Understanding the declaration here is to introduce variables into the program and specify its data type. Here are examples of variable declarations:






4. ASSIGNMENT
Assignment process is the process of giving value to a variable that was declared. Here is an example of assignment:
 






 5. CONSTANTS
For declaring constants in C + + is similar to Pascal. The syntax is:




6. COMMENT
Comments are used to explain the program and will not be executed in the program. Posting comments is as follows:









Thus the material this time, hopefully the material basics of the language C / C + + can help.
for the next entry we will learn about identifying the component / structure of a program, and learn fix the structure of the program is wrong.

Introduction of Programming Languages

This is my first entry in this blog, so first of all I will give some idea about the programming language C + +.

Programming language C / C + + is a popular language in teaching in computer science, as well as on the programmer who developed the system software and applications.

Language C / C + + its portable, because the compiler is available almost on all computer architectures and operating systems, so the investment of time and effort you are doing in learning the programming language has a strategic value that is very promising.

Language C / C + + is a language which is strict in the use of data type and the writing is case sensitive, this means that programmers are in demand discipline in the writing program.

Now we'll create a simple program which is quite easy and short.
we will create a program that will produce the output:
"Welcome to C + + Programming and Welcome to learn C + + Programming"

There are some things we need to know before making a program that is about the structure of the program to be created.

First we make the algorithm, for the program that we will create:
1. Start Program.
2. displays The output : "Welcome to C + + Programming and Welcome to learn C + + Programming".
3. end Program.
That is the algorithm of the program that we will create, then we will make it a script program.


Script Program:
_____________________________________________________________________________________________________
#include <stdio.h>                          //Header

void main()                                 //mian function
{
printf("Welcome to C++ Programming and Welcome to learn C++ Programming");    //output displays
}
_____________________________________________________________________________________________________


That script out the program to display the results in the form of the phrase "Welcome to C + + Programming and Welcome Programming C + +".


And this is the program output results that we have made:

Thus we are first learning programming by creating a simple program. thank you for studying with me. come back soon to learn the other programming.