C Programming IT Programming Tutorials

Keywords in C

One of the important tokens in C are keywords, identifiers, and constants. The keywords are reserved words that cannot be used as a variable name or as an identifier. There are 32 Keywords in C.

Keywords in C

The keywords are reserved words that cannot be used as a variable name or as an identifier. There are 32 keywords in C.

                                        List of Keywords in C programming

intvoiddodefault
charenumwhilestruct
floatautoforunion
Doublestaticswitchconst
Longexterncasetypedef
shortregistergotosizeof
signedifcontinuevolatile
unsignedelsebreakreturn

Identifiers in C

 The identifiers are used to represent variables, arrays, structures, unions, and functions. The identifier can include alphanumeric characters such as upper case(26), lower case(26)underscore(1),  and digits (0-9) all together a total of 63 characters can be used.  

Rules for writing an identifier

1. Keywords cannot be used as an identifier.

2. The first character of an identifier must be an alphabet or underscore, it should not begin with numbers.

3. The remaining characters of the identifier can be any of the alphabets, digits, or underscore.

4. The characters such as commas or blank spaces cannot be used in between the identifiers.

5. The identifier length must not exceed 31 characters.

Examples of valid identifiers:

 sum, avg, total_value, num1 etc.

Constants in C

Constants are fixed values that cannot be changed in a program. The constants are defined using the const keyword and the different types of constants are integer constants, character constants, floating-point constants, and string constants. The constants can also be defined using preprocessor directives, which we will discuss later.

 List of constants in C:

Decimal Constant50,100,2000,198 ….
Hexadecimal Constant0x2d, 0x4f, 0x3b…
Octal Constant050, 023, 052…
Floating-point Constant5.6, 30.6, 400.5…
Character Constant‘x’, ’y’, ’z’, ’a’, ’b’
String Constant“hello”, “welcome to programming”

Recommended Articles

Leave a Reply

Your email address will not be published. Required fields are marked *