Startertutorials Blog
Tutorials and articles related to programming, computer science, technology and others.
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.
Home » Programming » C Programming » C Tokens
Suryateja Pericherla Categories: C Programming. No Comments on C Tokens
4
(2)

This article provides a comprehensive overview of C tokens. We will learn what is a token and what are the different tokens in C programming language.

 

Visit our complete C programming tutorial.

 

Introduction

A programming language is designed to help process certain kinds of data consisting of numbers, characters and strings and to provide useful output known as information.

 

The task of processing data is achieved by writing instructions. These set of instructions is known as a program.


Subscribe to our monthly newsletter. Get notified about latest articles, offers and contests.


 

Programs are written using words and symbols according to the rigid rules of the programming language known as syntax.

 

Watch this video to learn about C tokens:

 

Character Set

The characters that can be used to form words, numbers and expressions depend upon the computer on which the program is run.

 

Characters in C, are grouped into the following four categories:

1) Letters

2) Digits

3) Special Characters

4) Whitespaces

 

The compiler ignores the white spaces unless they are part of the string constants.

 

White spaces are used to separate words from each other, but they cannot be used in between the characters of keywords and identifiers.

 

Tokens in C

In a paragraph of text, individual words and punctuation marks are considered as tokens.

 

What is a token?

In a C program, the smallest individual units are known as C tokens.

 

 C has six types of tokens as shown in the image below.  C programs are written using these tokens and the syntax of the language.

 

c tokens

Keywords

Every word used in a C program is classified as either a keyword or as an identifier.

 

What is a keyword?

A keyword in C is a reserved word which has a specific meaning.

 

Keywords in C cannot be used as identifiers. Keywords serve as the basic building blocks for program statements.

 

Keywords in C are always in lowercase.

 

 ANSI C supports 32 keywords which are listed in the table below. 

c keywords

 

Identifiers

What is an identifier?

Identifiers refer to the names of variables, functions and arrays. These are user-defined names and consist of sequence of letters and digits, with a letter as a first character.

 

Both uppercase and lowercase letters can be used, although lowercase letters are generally used. The underscore character is also permitted in identifiers.

 

 The rules for writing identifiers in C language are as follows: 
  • First character must be an alphabet or underscore.
  • Must consist of only letters, digits or underscore.
  • Only first 31 characters are significant.
  • Cannot use a keyword.
  • Must not contain white space.

 

In the next article, let’s learn about constants in C language.

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Leave a Reply

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

Facebook
Twitter
Pinterest
Youtube
Instagram
Blogarama - Blog Directory