Data type modifiers are used with primitive data types to change the meaning of predefined data types according to the situation.

C++ supports the following data type modifiers:

  • long: It is used to increase the length of a data type to 4 more bytes.
  • short: It decreases the available length of a data type to 2 bytes.
  • unsigned:unsigned allows us to store positive values only.
  • signed:signed allows us to store both positive and negative values.

Data type tells the compiler what type of data a particular variable can store. The compiler allocates the memory to the variable based on its data type.

Data types do the following two things:

  • Specify the type of value a particular variable can store, i.e., variable declared with int data type can store integer values only.
  • Reserve the number of bytes for a variable in memory, i.e., a variable with int type will reserve four consecutive bytes in memory. With 4 bytes, we can represent any value from -2147483648 to 2147483647. Therefore, the range of values that a variable can store depends upon its data type.

Constants are similar to variables except that we can’t change their value during the code execution.

In C++, we can use the const keyword to declare a constant. The basic syntax for creating a constant is:


const constant_datatype constant_name=constant_value

Example program

#include <iostream>

using namespace std;

int main() {

const int number = 10;

cout << “Number = “ << number << endl;


note:Constants are read-only variables. If you try to overwrite the value of the constant, an error will occur.

Giving a pet name to a baby is something different in our planet.c++ is planet,where each variable should be named by following identifier rules.

so,let’s understand the standard naming rules(AKA identifiers rules)

  1. Identifiers are names given to variables

Rules for naming a variable

The general rules for naming a variable are:

  • An identifier can only contain uppercase alphabets (A to Z), lowercase alphabets (a to z), numbers (0 to 9), and underscore (_).
  • The first letter of an identifier can be an alphabet or an underscore.
  • The first letter of an identifier cannot be a number.
  • C++ is a case-sensitive language. Therefore, an identifier written in the upper case will be different from one written in lower case.
  • An identifier cannot contain white space.
  • An identifier cannot have special characters such as &, @, *, !, etc.
  • We cannot use keywords as identifiers.

A variable declaration means that we want the compiler to reserve a space for a data with the given name and type.

To declare a variable that can store an integer value, we will write the following line:

#include <iostream>

using namespace std;

int main() {

int number;

We can declare more than one variable in a single line.

int number1, number2, number3;