Variables, literals, and Constants in C++ Programming Language

This tutorial about variables, literals, and constants in C++


 C++ Variables

variable gives us designated storage that our programs can add. Each variable in C++ has a specific type, which determines the amount and configuration of the variable's memory. The range of values that can be stored in this memory. And the set of operations that can be applied to the variable.

The name of a variable can consist of letters, numbers and an underscore character. It should start with a letter or an underscore. The uppercase and lowercase letters are separate because C++ is sensitive

There is the following basic type of variables and their uses.

  • Int - integer (whole number), without decimals, such as 123 or -123
  • Double-stores floating-point numbers, with decimals, such as 19.99 or -19.99
  • Float - stores a letter, such as 'a' or 'B'. The four values are surrounded by single references
  • String - stores text, such as "Hello World". String values are double prices on all sides
  • bool - stores values with two states: true or false


C++ Literals

In computer programming, there is literal a hint to represent a fixed value in a source code. ... An anonymous function is literal for type. Contrary to the literal meaning, variables or static symbols are symbols that can take one of a class of fixed values, forced to not change permanently.


The following is a list of the most common types of C ++.


Numeral literal: It is used to represent a constant mood.

Float Literal: This float is used to represent permanent.

Character Literal: Used to represent the same character.

String Literal: Used to represent a string of characters.

Boolean Literal: Used to represent Boolean (true or false).


C++ Constants


Refer to Constants values ​​that may not be altered in the program and may be called literal. Constants data can be one of the basic types and can be divided into integer digits, floating-point digits, characters, strings, and boolean values.

How to make or declare a Constants

You use the const statement to declare a Constant and assigned a new value. By declaring Constant, you assign a meaningful name to a value. Once a Constants declaration is made, it cannot be modified or a new value can be assigned. You declare a Constant within a procedure or in the announcement section of a module, class, or structure