KEYWORDS & IDENTIFIERS IN C

Dev Frank
3 min readDec 26, 2023

--

@Dev Frank

Keywords are reserved, predefined words or functions.

Keywords are like special words in our secret code that have very important meanings. When we use these special words, the computer knows exactly what we want it to do!

For example, imagine we have a keyword like “jump.” If we tell the computer “jump,” it knows we want it to make something on the screen go up! Keywords are like magic words that help us talk to the computer in a language it understands.

So, when we are writing instructions for the computer, we use these special words (keywords) to tell it what steps to follow. It’s like having a secret conversation with the computer using our special code words!

Keywords in C are reserved words that have predefined meanings and cannot be used as identifiers (variable names, function names, etc.). These words are part of the C language syntax and serve specific purposes in the code.

In ANSI C, there are 32 keywords, we can also say keywords are basic building block for writing instructions a C program.

KEYWORDS IN C

auto        double        int          struct
breeak else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
  • Keywords cannot be used as Identifiers.
  • Keywords begins with lowercase i.e. it is case sensitive.

IDENTIFIERS

Identifiers refers to a name of a variable, function, union, arrays, structure etc.

As the name implies it is used to identify variables, functions, union, etc.

They are chosen by the programmer and must adhere to specific rules. Identifiers provide a way to reference and manipulate data within the program. They are called IDENTIFIER because, it is user-defined i.e. we define their names.

Picture this: if you have a special number, you can give it a unique name like “myNumber.” Similarly, if you have a favorite color, you might call it “favouriteColor.” These special names, or identifiers, act like labels that make it easy for both you and the computer to keep everything organized and understand what each thing is doing. It’s like having a magical tagging system for all the important stuff

Rules In Defining Identifiers

  1. Identifier is a sequence of letters, numbers, and underscore. No special character are allowed when defining an identifier. Must begin with a letter (a-z, A-Z) or underscore _.

Subsequent characters can be letters, digits (0–9), or underscores.

Examples

_sum               (valid)            12frank      (Invalid)
calculateSum() (valid) $salary (Invalid)
Str_21 (valid) list&45 (Invalid)
NewAge (valid) point 08 (Invalid)

2. Identifier cannot be used as keywords.

Examples

int float;  // this wrong, you cannot used a keyword (float) as identifier 

int a; // this is valid you're declaring a variable.

NB: Identifiers are also called Variables.

3. According to ANSI C the first 31 characters are significant.

4. Unlike keywords where we only use lowercase letters, identifier can use both uppercase, lowercase & underscore

5. C is case-sensitive, so count and Count are different identifiers.

Keywords in C define the basic building blocks of the language. They convey specific meanings and are used to structure and control the flow of the program.

Identifiers in C are names given to various program elements such as variables, functions, arrays, etc. They are chosen by the programmer and must adhere to specific rules. Identifiers provide a way to reference and manipulate data within the program.

--

--

Dev Frank

Passionate tech enthusiast, diving deep into the world of software engineering. Thrilled to share insights with the world. A Software engineering student.