Lesson 2
Lesson 2
C Language Constructs
1. Character Set
2. Tokens
3. . Keywords
4. Identifiers
5. . Constants
6. . Variables
Character Set
The character set of C comprises of wide range of symbols that can be used to create tokens. These symbols are available on all modern personal computers. These characters can be grouped into following categories
1. Letters
2. Digits
3. Special Characters
4. White Spaces
Token
In C language the smallest unit of a program is called Token. Tokens are created using the C character set. These tokens are delimited from each other by white spaces just like words in English language are delimited by white spaces. The Syntax Rule of the C language dictates how to create tokens in C and how to use these tokens to create meaningful statements.
C language has 5 types of tokens
● Identifiers.
● Literals.
● Operators.
● Separators.
● Keywords.
KEYWORD
Keywords are predefined, reserved words used in programming that have special meanings to the compiler. Keywords are part of the syntax and they cannot be used as an identifier. Here, int is a keyword that indicates money is a variable of type int (integer)
A list of 32 Keywords in C
auto break const
double else float
int long short
struct switch Unsigned
IDENTIFERS
C identifiers represent the name in the C program, for example, variables, functions, arrays, structures, unions, labels, etc. An identifier can be composed of letters such as uppercase, lowercase letters, underscore, digits, but the starting letter should be either an alphabet or an underscore.
CONSTANTS
C Constants is the most fundamental and essential part of the C programming language. Constants in C are the fixed values that are used in a program, and its value remains the same during the entire execution of the program.
● Constants are also called literals.
● Constants can be any of the data types.
● It is considered best practice to define constants using only upper-case names.
Constant Types in C
● Numeric Constants. Integer Constants. Real Constants.
● Character Constants. Single Character Constants. String Constants. Backslash Character Constants.
VARIABLE
A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.
Sr.No. Type & Description
1 char
Typically a single octet(one byte). It is an integer type.
2 int
The most natural size of integer for the machine.
3 float
A single-precision floating point value.
4 double
A double-precision floating point value.
5 void
Represents the absence of type.