C keywords and identifiers

AkhileshwarReddyAnki 4,435 views 13 slides Oct 15, 2017
Slide 1
Slide 1 of 13
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

About This Presentation

About the Keywords and Identifiers in C. List of reserved keywords and where they can be used.


Slide Content

Keywords and Identifiers in C A.Akhileshwar Reddy

contents Character set C Keywords Idenifiers

Character set Character set is a set of alphabets, letters and some special characters that are valid in C language. Alphabet: Uppercase letters: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Lowercase letters: a b c d e f g h I j k l m n o p q r s t u v w x y z C accepts both lowercase and uppercase alphabets as variables and functions.

Digits: 1 2 3 4 5 6 7 8 9 0 We can use digits in the identifiers. But there some restrictions. Special Characters: Special characters in C language

C keywords Keywords are: predefined, reserved words used in programming that have special meanings to the compiler. Part of syntax and cannot be used as an identifier. Ex: int name; Here, ‘ int ’ is a keyword that indicates ‘name’ is a variable of type integer. As C is a case sensitive language, all keywords must be written in lowercase letters.

The list of keywords that are allowed in C & ANSI C languages are as follows. auto double int struct break else long switch case enum register typedef char extern return union continue for signed void do if static while default goto sizeof volatile const float short unsigned

Uses of keywords Data type Keywords int                 Specifies the integer type of value a variable will hold char             Specifies the character type of value a variable will hold float             Specifies the single-precision floating-point of value a variable will hold double        Specifies the double-precision floating-point type of value a variable will hold. Qualifier Keywords signed         Specifies a variable can hold positive and negative integer type of data  unsigned    Specifies a variable can hold only the positive integer type of data  short            Specifies a variable can hold fairly small integer type of data long             Specifies a variable can hold fairly large integer type of data

Qualifier Keywords signed          Specifies a variable can hold positive and negative integer type of data  unsigned     Specifies a variable can hold only the positive integer type of data  short             Specifies a variable can hold fairly small integer type of data long              Specifies a variable can hold fairly large integer type of data Loop Control Structure Keywords For                   Loop is used when the number of passes is known in advance While                Loop is used when the number of passes is not known in advance Do                     Loop is used to handle menu-driven programs

User-defined type Keywords typedef            Used to define a new name for an existing data type Enum               Gives an opportunity to invent own data type and define what values the variable of this data type can take Jumping Control Keywords Break              Used to force immediate termination of a loop, bypassing the conditional expression and any remaining code in the body of the loop continue         Used to take the control to the beginning of the loop bypassing the statements inside the loop Goto                Used to take the control to required place in the program 

Storage class keywords:

Identifiers An Identifier: refers to the name of an entity such as variable, function, structure, union etc. Must be unique. They are created to give an unique identity to an entity to identify it during the execution of the program. Ex: int name; double salary; Here, ‘name’ and ‘salary’ are identifiers, ‘ int ’ and ‘double’ are keywords. Name should be different from keywords. i.e. cannot use keywords as identifiers.

Rules for writing an identifier: 1. A valid identifier can have letteres , digits and underscores. 2. The first letter of an identifier should not be a digit or underscore. 3. First letter should be a letter either uppercase or lowercase. 4. There is no rule on length of an identifier 5. . The first 31 characters of an identifier are discriminated by the compiler.

Thank you