Subscribe:

Ads 468x60px

Kamis, 25 November 2010

COMMENT and TYPE VARIABLE DATA

1. Program Comments

To facilitate the reading process flow of a program, a programmer should write the comments in the syntax of the program. The definition of the commentary is part of the program itself (as text) in the program who was not executed during the compilation process. Comments in C made ​​by adding '/ *' and ends with'*/'.


2. Variable

The variable is a recognition in the program that allows you to save the value of a particular data type. The value stored in a variable is dynamic, meaning that value can be changed during program run. To use variables, of course we touched declare them first so the compiler can recognize them. Here are the general form for declaring variables in C language.



type name_variable _data;

For example:

int x; / * declare a variable x with type int * /


float y; / * declare a variable x with float data type * /


As for the terms of the naming of variables, namely:


1. C language is a language that is case-sensitive (use uppercase and lowercase letters in a very different variables),
2. The variable name must not be a number preceded by a character or a number. Example:

int 23 / ​​* incorrect * /

int s32 /*benar*/

int S32 / * true * /



1. The variable name must not contain spaces,
2. The variable name may not use the characters that are symbols (@,#,?, etc.).
3. The variable name must not use keywords or macro that has been defined in the C language

* Variable Scope

In a progarm, variable scope is determined by the spot where he declared. According to the scope, the variable can be divided into two, namely global variables and local variables.


1. Global Variables

Global variables are variables that are declared outside the function, both primary functions and other support functions.

2. Local Variables

Local variables are variables declared inside a function shingga can only be identified and accessed by function alone2.


* Variable Types

By type, variables in C can be divided into four kinds, namely automatic variables, static, external, and registers.


1. Variable Automatic

Automatic variables are variables known only within a block only (in sign {...}), either in block selection, repetition or function.

2. Static Variables

Is a variable that stores suati permanent value in a memory, meaning that the variable will store the last niali given.

3. External Variables

C language syntax allows us to write the program into a separate file with a program aimed to modularization. Therefore if we want to declare a variable that can be recognized and accessed by each of the separate file, then the variable that we have declare as external variables. As for how dalah adding the keyword extern at the time of declaration.

4. Register Variables

Unlike other variables that will be stored in memory, the register variables will be stored in CPU registers so that program execution will be faster.


*Data Type
The simplicity of this data type is, eg 10 is the data type integer, 11:45 is the real number data type and the 'A' type character.

1. Basic Data Type
In the language C are grouped into four categories, namely integer data type (integer), real numbers (floating-point), character or string and the type of logic (boolean).

3.1.1. Integer type

Integer type is a data type that is used to store the values ​​that shaped integers (numbers that do not contain a comma), eg 20, 10 and so forth. But the integer is divided again into 2 ie, positive integers and negative integers. In the C language integer divided in a certain range eg integer (int).

3.1.2. Type of Real Numbers

Is a number that contains the value of fractions (containing a comma), eg 1:20, 2:45 and so on.

3.1.3. Character and String Types

Used to represent data in the form of characters. Data will be considered as a character if enclosed by single quotation marks ("), such as 'A', 'B', 'C' and so forth. Whereas if enclosed by double quotes (""), it will be regarded as a string such as "A", "B", "C language" and so forth.

3.1.4. Logic Type
Is the data type that represents the true value (true) and false (false).

3.1.5. Data Type formation
It is self-defined data types to meet the needs of the program that we will create. As for which are included in the data type is the type of array formation and structure.

3.1.6. Enumersi
Is a data type whose value has been defined with certainty at the time of manufacture of that type. This type is generally used to express something whose value is certain, as the name of the day, month, and so forth. As for making a enumersi in C is to use the enum keyword.

0 comments:

Posting Komentar

Quote of the Day

if we plant the rice then it is definitely going to grow grass
but if we do not expect to plant grass to grow rice

if we do that then the world will follow hereafter
but if we do that the world then the afterlife will not participate

Followers