Introduction to variables, datatypes and operators in c++ programming language.

What is a variable?

Variables are the named memory location where the user can store different values of the same data types. In other words, variables are the storage container to store the different values of the same data type.

The value of the variables can be changed during the execution of the program. The name of the variable should be meaningful because it will make it easy to understand.

Example:- int a = 23; here a is variable.

What are Datatypes?

Datatypes are the declaration for variables. This determines the size and the type of data associated with variables. The most common datatypes are- int, char, bool, float and double.

What are operators?

Operators are the symbol that is used to perform mathematical and logical manipulation which means operators tells the compiler to perform mathematical or logical operations.

The operators that act upon the data items are called operands. Some operators require two operands, while some only need one to act.

Types of operators

  1. Arithmetic operators:- The arithmetic operator is the operator which is used to perform various mathematical operations like addition ( + ), subtraction ( - ), multiplication ( * ), division ( / ) and the remainder ( % ).

  2. Assignment operators:- Assignment operators is the operator in which the value of the operand on the left side is set equal to the operand on the right side.

    Types of assignment operators are:-

  3. Logical operators:- Logical operators are the symbols that are used to combine the different conditions into one. It has three types of operator:-

· Logical and (&&)

· Logical or (||)

· Logical not (!)

  1. Unary operators:- Unary operators is the operator which needs only one operand to perform operations. It is having two operators increment and decrement operators. The increment operator increases the value of the operand by one whereas the decrement operator decreases the value of the operand by one.

  2. Relational operator:- Relational operators are the operators which are used to compare the values of the operands and the result of such operations is always logical which means True or false.

  3. Bit-wise operator:- Bit-wise operator is the operator which operates at the bit level. It allows the user to manipulate the individual bits. These operators are used in the low-level language

  4. Conditional or ternary operator:- Conditional operator is the ternary operator which means it needs three operands. This operator is used in decision-making. In this first, we very condition if the condition is true, the first option is performed and if the condition is a false second option will perform.