C language

Program C does not know the rules of writing in a particular column, so it can be started from any column. However, for ease of reading programs and to documentation purposes, should be writing in C regulated in such a way that is easy and readable.

Views from the editor language C using Turbo C

  •  Data Type
The data type is part of the most important program because it affects the data type each instruction to be executed by the computer. For example, 5 divided by 2 can only produce different results depending on the type of data.If the integers 5 and 2 it will produce the value 2, but if both are of type float then it will generate the value 2.5000000. Selection of the appropriate type of data will make the operation process data more efficiently and effectively.

No Tipe Data Ukuran Range (Jangkauan) Format Keterangan
1 char 1 byte 128 s/d 127 %c string
2 int 2 byte 32768 s/d 32767 %i , %d Integer
3 float 4 byte 3.4E-38 s/d 3.4E+38 %f Float
4 double 8 byte 1.7E-308 s/d 1.7+308 %lf -
5 void 0 byte - - -

  • Constant
Constant is a value that can not be changed during the life of the program. The constant value is always fixed. Constants must be defined in advance at the beginning of the program. Constants can be integer value, fractions, characters and strings. Examples of constants: 50, 13; 3:14; 4.50005; 'A', 'C'. In addition, the C language also provides some special characters called the escape character, among others:
\ A: to sound the bell (alert)\ B: go back one space (backspace)\ F: replace the page (form feed)\ N: replace new line (new line)\ R: to the first column, the same line (carriage return)\ V: vertical tabulation\ 0: empty value (null)\ ': Char\ ": Double quote character\ \: Slash character

  • Variable
Variable is an identifier (identifier) used to represent a specific valuein the process of the program. Unlike the constant whose value is always fixed, the value of a variables can be changed as needed. The name of a variable can be determined by programmers with the following rules:

1. Consisting of a combination of letters and numbers with the first character must be a letter.2. C language is case-sensitive meaning uppercase and lowercase letters are considered different. So between the metal, the metal is different.3. Can not contain spaces.4. May not contain special symbols except underscore (underscore), like: $,?,%, #,!, &, *, (,), -, +, Etc..5. Free length, but only 32 first characters are used.
Examples of naming the wrong: NIM, a, x, nama_mhs, f3098, f4, values, kindness, etc..Examples of naming the wrong variable: nilai_mahasiswa, 80% of the students, on average, no space, it is important!, Etc..

  • Variable Declaration
The declaration is necessary if we are going to use the identifier (identifier) in the program. Identifiers can be variables, constants and functions. The general form of declaring a variable is:

Nama_tipe nama_variabel;Example:int x;char y, letters, NIM [10];float value;double beta;int array [5] [4];

This article from klikbelajar.com