Character Constants, Symbolic Constant, Logical Constant, C Tokens Assignment Help

Assignment Help: >> Constants >> Character Constants, Symbolic Constant, Logical Constant, C Tokens

Character Constants

These are four types of character constants:

1.       Single Character Constant

2.       String character Constant

3.       Back slash character constant

4.       Enumerated Constant

Single character constant

A character constant is either a single alphabet, a single digit, or a special symbol enclosed with in a pair of single inverted (' ') commas. It also has its ASCII VALUE.

 

Characters

ASCII VALUES

A-Z

a-z

0-9

Special Symbols

65-90

97-122

48-57

0-47, 58-64, 91-96, 123-127

 

Examples:-­
'5'                'xy'
 '

               '= 0'
'#'               '378'
(valid)        (invalid)

 

698_characters-constants.png

Fig: Classification of character constants

String character constant

These are the group of characters enclosed within pair of (" ") quotation. The Last character of string is NULL ('\0').this character acts as a string termination, using this fact we can find out where string ends
Example:-"LALIT MATOLIYA"

    "SYSTEM SOFTWARE DEVELOPER"

 

Escape sequence/backslash character constant

It is used to represent the nonprintable characters (new line, tab, ("\t") mark) etc. "An escape sequence is a 'substitute character' for printing hard to get characters". These are the combination of backslash (\) with 'C' character set.

 

Back Slash Character

Response

\a

Alert Bell

\n

New Line

\"

Quotation mark

\b

Back Slash

\r

Carriage return

\f

From feed

\v

Vertical tab 

\o

Null

\t

Horizontal tab

\\

Back slash

 

There are two characters but they are treated as a single character. It can be stored in character type variable

Enumerated character constant: It is fixed set of values. But only one value is assigned at a time. For Example : enum colour (blue, red, green, purple, white, yellow);

Symbolic Constant

It is the name that use for a sequence of characters. It can be used several times in our program.

Example:  #define <name> <value>

 

Logical Constant

A logical constant can take either of two values true or false. A nonzero value treated as true. A zero value treated as false. Logical constants are very useful in evaluating logical expressions.

 

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd