C tokens.pptx

NavyaParashir 174 views 15 slides Sep 20, 2022
Slide 1
Slide 1 of 15
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15

About This Presentation

c tokens types


Slide Content

C tokens

keyword Every c word is classified as either a keyword or an identifier. All keywords have fixed meaning and this cannot be changed. All keywords must be written in lowercase. Examples: int,break,char,if,else,float,return,void.. etc

Identifiers It refers to the names of variables, functions and arrays. These are user defined names and consists of a sequence of letter and digits but only with letter as a first characters. Both uppercase and lowercase letters are permitted.(most commonly used are LC Letters)

Rules for identifiers First character must be an alphabet(or underscore.) Must consist of only letters, digits or underscore. Only first 31 characters are significant. Cannot use a keyword. Must not contain white space.

constants Constants in c refer to fixed values that do not change during the execution of a program.

Integer constants An integer constant can hold an integer as its value. There are three types of integer constants, namely, decimal integer, octal integer and hexadecimal integer. Decimal integer consists of a set of digits from 0 to 9, preceded by an optional + or – sign. Examples: 123 , -321 , 0 , 64932.

continued Octal integer consists of a set of digits from 0 to 7, with a leading 0. Examples: 037 , 0 , 0437, 0551. Hexadecimal integers are a sequence of digits preceded by 0x or 0X. They may also includes letters from A to F or from a to f. The letters represents the numbers from 10 to 15. Examples: 0X2 , 0x9F , 0Xbcd , 0x.

Real constants Real constants can be assigned real values, that is values with floating points. Real constants are used to represent quantities that are very continuous, such as distances, temperature etc. These quantities are represented by numbers containing fractional parts. Examples:- 0.00832 , -0.75 , 33.337.

Single character and a string constants Single character constants: A single character constants contains a single character enclosed within a pair of single quote marks. Examples:- ‘5’ ‘X’ ‘;’ String constants: A string constant contains a string of characters enclosed within a pair of double quote marks. Examples:- “Hello !” “1987” “?….!”

strings In C programming, a string is a sequence of characters terminated with a null character \0. For example: char c[] = "c string"; When the compiler encounters a sequence of characters enclosed in the double quotation marks, it appends a null character \0 at the end by default.

operators Arithmetic Operators. Relational Operators. Logical Operators. Assignment Operators. Increment and decrement operators.(or unary) Conditional Operators(or ternary). Bitwise Operators. Special Operators.

Special symbols The special symbols have some special meaning in c programming and they cannot be used for other purposes. Some of the special symbols that are used in C programming are as follows :− [] () {} , ; * = #

Brackets[] − Opening and closing of brackets are used for array element reference, which indicate single and multidimensional subscripts. Parentheses() − These special symbols are used for function calls and function parameters. Braces{} − Opening and closing of curly braces indicates the start and end of a block of code which contains more than one executable statement. Comma (, ) − It is used to separate more than one statements like separating parameters in function calls.

Colon(:) − It is an operator which essentially invokes something called as an initialization list. Semicolon(;) − It is called as a statement terminator that indicates the end of one logical entity. That is the reason each individual statement must be ended with a semicolon. Asterisk (*) − It is used to create a pointer variable. Assignment operator(=) − It is used for assigning values. Pre-processor (#) − The pre-processor called as a macro processor is used by the compiler to transform your program before the actual compilation starts.
Tags