Menu
×
Tutorials Ms Word Tutorial Ms Excel Tutorial Ms PowerPoint Tutorial C Language Tutorial C++ Tutorial C Sharp Tutorial Visual Basic Tutorial HTML Tutorial CSS Tutorial JavaScript Tutorial WordPress Tutorial
     ❯   

ADVERTISEMENT

Keywords and Identifiers In C

Identifiers

A C identifier is a name that is used to find a variable, function, or anything else that was created by the user. It starts with a letter (A to Z, a to z) or an underscore (_), and then it has zero or more letters, underscores, or digits (0 to 9).

It is not possible to use punctuation like @, $, and % in identifiers in C. When you write code in C, the case of the words matters. This means that Manpower and manpowerare not the same thing in C.

These are some examples of good identifiers:

amount
salary
abc
Move_name
abc_123
name10
_temporary
i
x12z34
returnVal

Keywords

The words that can’t be used in C are shown below. There are some words that can’t be used as constants, variables, or any other kind of identifier names.

These are some Reserve Keyword:

auto
else
long
switch
break
enum
register
typedef
case
extern
return
union
char
float
short
unsigned
const
for
signed
void
continue
goto
sizeof
volatile
default
if
static
while
do
int
struct
_Packed
double

Whitespace In C

A line withonly whitespace, maybe a comment, is called a blank line, and a C compiler doesn’t care about it at all.

int age;
C Programming

The compiler can tell the difference between int and age if there is at least one whitespace character between them. This is usually a space. In the following sentence, on the other hand.

fruit = apples + oranges;   // get the total fruit
C Programming

There is no need for whitespace between fruit and = or between = and apples, but you can add some if you want to make the text easier to read.

Rules for naming identifiers

  1. A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores.
  2. The first letter of an identifier should be either a letter or an underscore.
  3. You cannot use keywords like int, whileetc. as identifiers.
  4. There is no rule on how long an identifier can be. However, you may run into problems in some compilers if the identifier is longer than 31 characters.
Spread the love
Scroll to Top
Scroll to Top