C++ Tokens

C++ Tokens are the individual words and punctuation, which is the smallest element of a program, understandable by the compiler. In easier language, C++ tokens are individual units in a program.

In this lesson, we will learn about the following Tokens in C++:

  1. Identifiers
  2. Keywords
  3. Whitespace

C++ Identifiers

Identifiers in C++ are used for naming variables, functions, and arrays. Do not use keywords as identifiers. You cannot use keywords as identifiers; they are reserved for special use.

Here are some examples of valid identifiers:

Rules for naming Identifiers in C++

To name C++ Identifiers, follow these rules:

  1. The identifier must begin with a letter or underscore (_).
  2. C++ identifiers must consist of only letters, digits, or underscores.
  3. Do not add any special characters to the identifiers.
  4. It should not be a keyword.
  5. It should not contain any white space.

C++ Keywords

Keywords are reserved words used in programming languages. The compiler already knows these names, so you cannot use them as variable names,

Over 30 keywords are part of C++ and are known to the compiler.

Here is a list:

Keywords in C++

C++ Whitespace

White space in C++ includes vertical tabs, horizontal tabs, blank, comments, end-of-line, etc. A line with whitespace isn’t considered by the compiler.

You can add a comment there, as shown below:

Use whitespace to separate parts of statements; for example:

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others:


For Videos, Join Our YouTube Channel: Join Now


Read More:

C++ Constants
C++ Strings
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading