C character set


          The character that can be used to form words,number and expressions depend upon the computer on which the program is run.

   
The character in C are grouped into the following categories.
  • Letters
  • Digits
  • White spaces
  •  Special characters
   Letters:
 
  •  Uppercase A to Z. 
  •   Lowercase a to z.
 Digits:

  •   0 to 9 
White space:
  • Blank space
  • Horizontal tab 
  • Carriage return
  • New line
  • Form feed
Special characters:



Constants:

  •  Constants in C refer to fixed values that do nto change during the execution of a program.
  • C supports several type of constants see the primary constants as below.
                       


1. Integer Constants:
  • An integer constant refers to a sequence of digits.
  • It contains of set of digits,0 to 9, preceded by optional - or + sign.
  • It must be have a decimal point.
  • valid example: 123 ,  -12  ,  0  ,  +78  ,  654321
  • Invalid: 15 750 ,  20,550  ,  $123
2.Real constants: 
  •  A real constants refer to a sequence of digits the point.
  • Number containing fractional parts like 15.55 such number are called real(or floating) constants.
  • Valid e.g. 0.0043
                        -0.75
                       +132.0
  • Invalid: 15.750 ,  20,550.33 ,  +$132

3.Single Character constants



  • A single character constant contain a single character enclosed within a pair of single quote marks.
  • Each character constant represents an integer value.
  • e.g :  '5'  ,   'x'  ,   ';'  ,  ' '
  • Note that the character constant '5' is not the same as number 5.
  • The last constant is a blank space.
character constants have integer value knows as ASCII (American code for information interchange) values.
   
       printf("%d",'a');

       I will print the number 97, the ASCII value of the letter a.

       printf("%d",97);
       It will print the letter 'a'.


4. String Constants:
  •  A string constants is a sequence of character enclosed in double quotes.
  • The character may be letters,numbers,special character and blank space.

  • e.g: "Hello" , "1947" , "welcome" , "5+6"  ,  "x"

  •  Character constants ('X') is not equivalent to the single character string constant ("X").
  • A single character string constants does not have an equivalent integer value while a character constants has an integer value.






 

No comments:

Post a Comment