What is

**Constants**and**Variables**in**C/C++**- Definition & full Explanation of**Variables**&**Constants**in**C/C++ Language**...##
**Constants and Variables in C++**

###
**Constants;**

Constants are the expressions which have a fixed value. Constants are generally categorized into Literal, Boolean and Symbolic constants. They are used to ad value permanently to a

**variable**in the program.Consider the following line of code:

**VarA = 777;**

In this line of code, 777 is a literal

**constant**. Further categorized literal**Constants**into the following types.-
**String constant** **Numeric constants****Character constants**

**1. String Constants:**A string

**constant**is a sequence of characters enclosed in the

**double quotation**("This is double quotation") makes is called string

**constant**. Its maximum length is 256 characters. Following are some examples of valid string

**Constants**.

**“Welcome to the first**

**C++**

**program”**

**“The result=”**

**2. Numeric constants:**These

**Constants**consist of positive and negative both of signed numerals. There are four types of numeric

**Constants**. These are:

**Integer constant****Octal constant****Hexadecimal constant****Floating constant**

**integer**

*Integer constants:***Constants**are those positive or negative signed numbers that do not contain a decimal point e.g. 2010, -230, etc.

*Floating point constants*

**:**The numeric

**Constants**having a decimal point are called floating point

**Constants**e.g. 33.55 and -0.22 etc. This

**constant**can also be either positive signed or negative-signed. These

**Constants**can also be represented in its exponential form by the use of alphabet ‘e’ or ‘E’ to denote the example of the numbers. For example.

**9010E10****7810.11e-11****-10.990e8****-1.001e-1**

**To represent a hexadecimal**

*Hexadecimal constants:***constant**, start the

**constant**with 0x or 0X, followed by a sequence of digits in the range 0 through 9 and a through f (or A through F). The digits

**Int I = 0x3fff; // Hexadecimal constant**

**Int j = 0X3FFF; // Hexadecimal constant**

*Octal constants:***Constants**representation in the octal number system is called octal

**Constants**. Octal constant begins the specification with 0, which followed by a sequence of digits in the range 0-7. Consider the following example:

**Int I = 0377; // Octal constant**

**Int j = 0397; // Error: 9 is not an octal number**

**Octal numbers are**

**integer**numbers in the range of digits 0 to 7.

**3. Character constants:**A character enclosed within single quotes is called character

**constant**. Consider the following examples:

**‘A’, ‘a’, ‘.’, ‘?’**

###
**Variables;**

A

Consider the following segment of code:**variable**in**C++**is a name for a price of memory that can be used to store information. A**variable**can be thought of like a mailbox where information can be put and retrieved from. All computers have memory, called Random Access Memory (**RAM**) that is available for programs to use. When a**variable**is declared, some space in that memory is reserved.

**Int a = 5;**

**Int b = 2;**

**Int result = a-b;**

In this segment, a, b and the result are the

**integer****Variables**that reside in RAM and store**integer**values.
ConversionConversion EmoticonEmoticon