What is Element of C language?
Every language has basic element and its own grammatical
rules. Before starting programming we must to know basic of programming and its
element. Elements C are-
1.
Character Set: The character set that are
used in C program according to user.
i.
Alphabets :
Capital A, B, C, D, E, F,
G……………..Z
Small a, b, c, d, e, f, g, h, I……………….z
ii.
Digits
All the number 0 to 9 are digits
e.g. 1, 2, 3, 4,5, 6, 7, 8, 9,0
iii.
Special Characters : Special characters are used in the program
for specific task each character has its own meaning in the program just like & used
for address, ++ used for increment, []
used for array, * sign for pointer etc.
Character
|
Meaning
|
+
-
*
<
>
(
)
\
{
}
[
]
;
:
“
‘
?
&
@
$
|
Plus sign
Minus sign(hyphen)
Asterisk
Less than sign
Greater than sign
Left parenthesis
Right parenthesis
Backward slash
Left braces
Right braces
Left bracket
Right bracket
Semicolon
Colon
Double quotes
Single quotes
Question marks
Ampersand
At the rate
Dollar sign
|
2.
Escape Sequences: Execution character
or escape character represented by two characters. The first character is
“\”and second character is from the C character set. Escape character always start with “\” symbol
for e.g. \n . these character combination is known as escape character and it
is very use full in the c program. C supports some Escape sequence that has its
own meaning. Blank, horizontal, vertical tab newline, carriage return, form
feed also known as whitespace.
Escape
Sequence
|
Meaning
|
ASCII Value
|
Why use
|
\b
|
Back Space
|
008
|
Moves the cursor to the previous position of the
current line.
|
\a
|
Bell alert
|
007
|
Generate a beep sound for alert.
|
\n
|
New line
|
010
|
Move the cursor at beginning of the next line.
|
\r
|
Carriage return
|
013
|
Move the cursor to beginning of the current line.
|
\0
|
null
|
000
|
for null
|
\f
|
Form feed
|
012
|
Moves the cursor to the initial position of the
next logical page.
|
\t
|
Horizontal Tab
|
009
|
moves the cursor to the next horizontal tab. 5
space at a time.
|
\v
|
Vertical tab
|
011
|
Moves the cursor to the next vertical tab.
|
\\
|
backslash
|
092
|
Print the character with (\).
|
3.
Trigraph Character: There is a
possibility that the keyboard doesn’t print some character.C support the facility of “trigraph sequence” to print
these characters. This trigraph has three characters. First two are ‘??’ and
third character is any character of C character set .
Trigraph
|
Symbol
|
??<
??>
??(
??)
??!
??/
??=
??-
??’
|
{
}
[
]
|
\
#
~
caret
|
4.
Delimiters: Delimiters are used for
Syntactic meaning in C.that have a specific task in the program.
: Colon used
for label
; Semicolon end of
statement
( ) Parenthesis used in
expression
[ ] square brackets used for array
{ } Curly Braces used for
block of statement
# Hash preprocessor
directive
‘ Comma variable delimiter
5.
Reserved Word /Keyword: Reserved
Words are that word which are reserved for doing specific tasks. These words are known as keywords and they have standard, predefined meaning in C.keywords always written in lowercase. there are 32 keywords in c language.
for example. auto, break, case, char, const, continue, default, do, double, else, enum, extern, float, for, goto, if, int,long,register, return, short, sizeof, static, struct, switch, typedef, union, void, volatile, while.
Identifiers : All the words that we will use in our C programs either keyword or identifiers.keywords are predefined and can't be changed by user, while identifiers are user defined words and are used to give name to entities like variables, array , functions,structure etc. Rules for naming identifier are-
- The name should consist of only alphabets (both upper and lower case), digits and underscore sign(_).
- first character should be an alphabet or underscore.
- The name should not be a keyword.
- Since C is case sensitive, the uppercase and lowercase letters are considered different. e.g CODE , code both are different.
- An identifier name may be arbitrarily long. some implementation of c recognize only the first eight character , though most implementation recognize 31 characters. ANSI standard compilers recognize 31 character.
Some Valid identifier is : 1. Value
2. a
3. net_save
4. _save
5. SAVE
Some Invalid identifier is: 1. 9ab
2. float
3. rd#
4. a b
Note:
- in the first 9ab, first character should be alphabet or underscore sign so it is invalid identifier.
- in second float, float is a keyword so it is invalid.
- in the third rd#, # is the special character so its also invalid.
- in fourth a b, space is not allow in identifier.