top of page
Writer's pictureApurba Paul

Variable and Data Types_1:The C character set identifiers and keywords

What are Keywords in C?

Keywords are reserved words that have special meaning in C language. The meaning of C language keywords has already been described to the C compiler. These meanings cannot be changed. Thus, keywords cannot be used as variable names because that would try to change the existing meaning of the keyword, which is not allowed. (Don't worry if you do not know what variables are, you will soon understand.) There are total of 32 keywords in C language.


What are Identifiers?

In C language identifiers are the names given to variables, constants, functions, and user-define data. These identifiers are defined against a set of rules.

Rules for an Identifier

An Identifier can only have alphanumeric characters(a-z , A-Z , 0-9) and underscore(_).

The first character of an identifier can only contain the alphabet(a-z , A-Z) or underscore (_).

Identifiers are also case sensitive in C. For example, name and Name are two different identifiers in C.

Keywords are not allowed to be used as Identifiers.

No special characters, such as semicolon, period, whitespaces, slash or comma are permitted to be used in or as Identifiers.

When we declare a variable or any function in C language program, to use it we must provide a name to it, which identified it throughout the program, for example:


int myfirstvariable = 2020;

Here myfirstvariable is the name or identifier for the variable which stores the value 2020 in it.

Character set

In C language characters are grouped into the following catagories,


Letters(all alphabets a to z & A to Z).

Digits (all digits 0 to 9).

Special characters, ( such as colon :, semicolon ;, period ., underscore _, ampersand & etc).

White spaces.


MCQ on Keywords and Identifiers:


1. C99 standard guarantees uniqueness of __________ characters for internal names. a) 31 b) 63 c) 12 d) 14

2. C99 standard guarantees uniqueness of ___________ characters for external names. a) 31 b) 6 c) 12 d) 14

3. Which of the following is not a valid variable name declaration? a) int __a3; b) int __3a; c) int __A3; d) None of the mentioned

4. Which of the following is not a valid variable name declaration? a) int _a3; b) int a_3; c) int 3_a; d) int _3a

5. Why do variable names beginning with the underscore is not encouraged? a) It is not standardized b) To avoid conflicts since assemblers and loaders use such names c) To avoid conflicts since library routines use such names d) To avoid conflicts with environment variables of an operating system

6. All keywords in C are in ____________ a) LowerCase letters b) UpperCase letters c) CamelCase letters d) None of the mentioned

7. Variable name resolution (number of significant characters for the uniqueness of variable) depends on ___________ a) Compiler and linker implementations b) Assemblers and loaders implementations c) C language d) None of the mentioned

8. Which of the following is not a valid C variable name? a) int number; b) float rate; c) int variable_count; d) int $main;

9. Which of the following is true for variable names in C? a) They can contain alphanumeric characters as well as special characters b) It is not an error to declare a variable to be one of the keywords(like goto, static) c) Variable names cannot start with a digit d) Variable can be of any length

3 views0 comments

Recent Posts

See All

Comments


bottom of page