Wednesday, October 26, 2011

Rules for Constructing Character Constants

(a)A character constant is a single alphabet, a single digit or a single special symbol enclosed within single inverted commas. Both the inverted commas should point to the left. For example, ’A’ is a valid character constant whereas ‘A’ is not.

(b)The maximum length of a character constant can be 1 character.

Ex.: 'A'
'I'
'5'
'='

3 comments:

  1. can we write any character name in single quotation mark?
    e.g. 'hello'

    is it correct?

    ReplyDelete
    Replies
    1. No this could not be treated as a character constant as in character constant the maximum length is of 1 character only

      Delete
    2. Not correct since the maximum number of character must be one.

      Delete