Showing posts with label Symbols and Operators.. Show all posts
Showing posts with label Symbols and Operators.. Show all posts

Variable, Symbols and operators.

A Variable is data name that may be used to store a data value it remains changed during the execution as a program example it takes different values at different times. It is a symbolic name given to the memory location where the data is stored the user is allowed to access the memory location through this variables name are declared in the begining of a program before the executional statements in the program.

Rules for Variables:

1. They must begin with letter some systems permit underscore as the first character.
2. ANSI 'C' recognizes 31 characters. But generally 8 characters are used for variable naming.
3. Uppercase lower case variables are treated as different variables.
4. Variable name should not be a keyword.
5. White space is not allowed.

Example:

Name
Place
Age
x1
R-Value

Symbols and Operators:

'C' Supports some special characters for specific purposes.

Example:

[ ]
( )

Operator is a symbol which performs some action on operators.

Example:

+, -, *, /, %, <, >, >=, <= etc.

Short notes.

'C' Character set:

The characters in 'C' are grouped in to following categories.

1. Letters - A-Z, a-z
2. Digits - 0-9
3. Special characters.
4. White spaces.

'C' tokens:

Individual words and punctuation names are called tockens.

In a 'C' program the smallest individual units are known as 'C' tockens. They are grouped in to Identifiers, Keywords, Constants, Symbols and Operators.

Identifiers:

Identifiers refer to the names of the variable function and arrays. These are user-defined names.

Rules of Identifiers:

1. Identifiers may contain sequence of letters and digits with a letter as first character, 2. Both uppercase and lower case letters are commonly used but uppercase variable and lower case variable are permitted.

Example:
             main
             amount

Keywords:

All keywords have fixed meaning and these meaning cannot be changed. Keywords save as a basic building blocks for program statements all the keywords must be written in lower case.

Example:
            float
            white

Constants:

Constants refer to fixed values that don't change during the execution of a program 'C' supports several types of constants, as shown below.

Constants - Numeric, Character.
Numeric - Integer, Real.
Character - Single character, String.

Integer Constant:

They refer to sequence of digits there are three types of integers.

1. Decimal Constant: It consists of set of digits 0 of through 9. Example: -123, 9.
2. Octal Constant: It consists of set of digits 0 through 7 with leading 0. Example: 037, 0. Rules: May be precedent by on optional + or -.
3. Hexa Decimal Constant: A sequence of digits preceded by ox. They may also include alphabets A through F, 10 represent No. 10 to 15. Example: ox2, ox9F Rules: Embedded  spaces, Commas, & non digit characters are not permitted.

Real Constants:

These quantities refer to the nos containing fractional part A real no may also be expressed in exponential notation. Example: 0.00083, -0.75.

Single Character Constant:

A single character constant refer a single character closed with in pair of single quote mark character constant have integer value known as ASCII value. Example: 'S', 'X', 'A'.

Back Slash Character Constant or Escape Sequence:

'C' Supports some special back slash character constants that are used in output functions although they consist of 2 characters the represent one character. These character combinations are know as Escape sequences. For example in represents new line character.
'\a' - alert (bell).
'\b' - Back Space.
'\f' - form feed.
'\n' - New line.
'\r' - Charrage return.
'\t' - Horizontal tab.
'\v' - Vertical tab.
'\'' - Single quote.
'\"' - Double quote.
'\?' - Question mark.
'\0' - Null character.

String Constant:

A string constant is a sequence of characters enclosed in double quotes. Example: "Hello", "Good", "r".