Search This Blog


Showing posts with label Tokens. Show all posts
Showing posts with label Tokens. Show all posts

Monday, September 16, 2019

#4 Tokens of C

➤Datatypes :-

  •  A datatypes defines a domain of allowed values and the operations that can be performed on those values.
  • Storage representation of different datatypes is different in memory.
  • There are four fundamental datatypes in C, which are int,char,float and double.

  ⏩ char is used to store any single character

  ⏩ int is used to store integer value 

  ⏩ float is used for storing single precision floating point number

  ⏩ double is used for storing double precision floating point number 

We can use type qualifiers with these basics types to get some more types.
There are two types of type qualifiers:-
  1. Sign qualifiers  - signed, unsigned 
  2. Size qualifiers  - short, long
  • The qualifiers signed and unsigned can be applied to char and integer types.
  • When the qualifier unsigned is used the number is positive.
  • When the signed is used number may be positive or negative.
  • If the sign qualifier is not mentioned in integers, then by default signed qualifier is assumed.
  • If the sign qualifier is not mentioned for char type, then its depend on machine.
  • The range of values for signed data types is less than that of unsigned type.
  • The qualifiers short and long can be applied to int type to get types short int and long int.
  • The qualifiers long can be applied to double to get type long double.
 The size and range of different datatypes on a 16-bit machine is given in the following table.The size and range may vary on machines with different word sizes.

  1. char data types:- 1 bytes 
  2. int data types :- 2 bytes(int),1 bytes(short int), 4 bytes (long int)
  3. float data types :- 4 bytes
  4. double data types :- 8 bytes(double), 10 bytes(long double)

 ➤ Format specifier/Type specifier :-

  •  Format specifier or type specifier is used for input and output .
  • It tells the compiler about the which type of variable is taken during the inputting and outputting.

      ⏩Some format specifier are:-

  • %c    -     character
  • %d,%i    -   integer
  • %f    -    float
  • %s    -    string
  • %u    -    unsigned decimal integer
  • %o     -    unsigned octal char , etc
If you want full list then comment below👇

Sunday, September 15, 2019

#3 Tokens of C

➤Delimiters :-

 Delimiters are used for syntactic purpose in C.

Delimiters are:-

  • :    colon                     used for label
  • ;    semicolon              end of statement
  • ()   parentheses           used in expressions
  • []   square brackets     used for arrays    
  • {}  curly braces           used for block of statements
  • #    hash                       preprocessor directive
  • ,     comma                   variable delimiter

➤Identifiers :-

  • Identifiers are user defined words .
  • They are used to give names to entities like variables,arrays, functions, structures etc.

   ⏩Rules for naming identifiers are given below:-

  1. The name should consist of only uppercase and lower case letters, digits and underscore sign(_).
  2. First character should be an alphabet or underscore.
  3. The name should not be a keyword.
  4. Blank space is not permitted .
  5. Since C is case sensitive, the uppercase and lowercase letters are considered different. For new, New and NEW are three different identifiers.

➤Expressions :-

  •  An expressions is a combination of operators, constants, variables and functions calls. 
  • An expressions can be arithmetic , logical or relational.

Some examples of expressions are:-

               x+y        - arithmetic operation
               a=b+c    - uses of two operator(=) and (+)
               a>b        - relational expression
               a==b      -logical expression
               func(a,b)-function call

➤Comments:-

  • Comments are used for increasing readability of the program.
  • They explain the purpose of the program.
  • There can be single line or multiple line comments.
  • The closing delimiter can't be used inside a comment.
comments are written as:-
                              /* statements to be comment */
                                             or
                              // statements to be comment

Saturday, September 14, 2019

#2 Tokens of C


➤ Escape sequence

  • C supports the combinations of backslash ( \ ) and some characters from the C character for representing these characters in our C programs.
  • These combinations are known as escape sequence and are represented by two characters.
  • The first character is "\" and second character is from the C character set.

Some escape sequence are:-

  1.     \b = backspace
  2.     \a = alert
  3.     \r = carriage return
  4.     \n = newline
  5.     \f = form feed
  6.     \0 = null character
  7.     \v = vertical tab
  8.     \t = horizontal tab
  9.     \\ = backslash

➤ Keywords/Reserved words

  • There are certain words that are reserved for doing specific tasks. They are known as keywords.
  • They have standards and predefined meaning in C.
  • They are always written in lowercase.
  • There are only 32 keywords available in C.

All 32 keywords are:-

  1. auto
  2. break
  3. case
  4. char
  5. const
  6. continue
  7. default
  8. do
  9. double
  10. else
  11. enum
  12. extern
  13. float
  14. for
  15. goto
  16. if
  17. int
  18. long
  19. register
  20. return
  21. short
  22. signed
  23. sizeof
  24. static
  25. struct
  26. switch
  27. typedef
  28. union
  29. unsigned
  30. void
  31. volatile
  32. while

Friday, September 13, 2019

Tokens of C language

Tokens:-

 Tokens are the smallest unit,which are used to create a program in any programming language.

There are some tokens in C:-

  1. Character set
  2.  Constant
  3. Variable
  4. Operator
  5. Data type
  6. Keywords
  7. Escape sequence
  8. Format specifier/type specifier
  9. Identifier
  10. Comment
  11. Delimeter
  12. Expressions

 ➤ Character set:-

 It represents different types of character, that are categorized into three parts.
  • Alphabet (A-Z) or ( a-z)
  • Digit (0-9)
  • Special character (@,$,%, etc)

➤Constant:-


  •  It is a fixed value which cannot be changed during execution of program. 
  •  It is also known as literal.

It can be divided into three parts :

types of constant,types of constant in C
types of Constant

  ⏩ Character Constant :

      It represents only single character that must be enclosed within single cot.
       eg:- 'A' , '6' , 'm' , '$' , etc.

  ⏩ String Constant :

  • It is a group of zero, one or more characters which are enclosed within double cot.
  • It must be terminated with null character (\0).
  • Null character represents ending of character in string.
  eg:- "coc" ⇒ c o c \0  (written inside it ⃢⃢⃢⃢)
          "1"    ⇒ 1 \0  (written inside it ⃣⃣)
                                 
       ⤔here "\0" denotes end of the character

➤ Variables :-

 Variables is a storage/memory location which is used to store constant value according to             requirement.
The value of variable can be changed during execution of program.
   eg:-
           a  = 10                                  
                      b  = 10.5
                name  = "xyz"
                    ch   = 'A'
    ➳here:- a,b,name and ch are variables. 

There are two types of variable:-

  • Local Variable
  • Global Variable

 ⏩ Local Variable:-

  • This type of variable must be declared within any particular function.
  • It provides local accessibility.
  • It means , these variable can not be accessed outside function.

 ⏩  Global Variable:-

  • These variables must be declared outside function.
  • It can be accessed outside function.
  • We can say that it provides global accessibility.   

 ‎