Thursday 22 March 2018

Variables

"A variables is a temporary container to store information , it is a named location in computer memory where varying data like numbers and characters can be stored and manipulated during the execution of the program".
A variable must be declared before it is used.It is a must because the compiler wants to be aware of it.

Types of Variables

Basically there are two types of variables , namely
 1. local Variable
 2. Global Variable

Local Variable 
  The local variable is created when the functions gets control and is destroyed when the control transfers back to the caller.

Global Variable
  Whereas the Global Variable is known and accessible throughout program.Global Variables are declared at the top of the module.

Declaration of Variable
  The declaration of a variable is simple in C++ language.It begins with the data type, followed by at least a space, followed by the name of a variable with a semicolon. Space is optional before the semicolon.

For Example

  int my_Age;
  int my_Salary;
  int_employee;

If different variable are using the same data type on the same line are also allowed,but care must be taken to separate two with a comma except the last one that would end with a semicolon.

Initialization of variables

   When the variables in the example above are declared, they have an undetermined value until they are assigned a value for the first time.But it is possible for a variable to have a specific value from the moment it is declared.This is called the initialization of the variable.
      type identifier = initial_value;
For example, to declare a variable of type int called x and initialize it to a value of zero from the same moment it is declared,we can write:
     int x = 0;

0 Comments:

Post a Comment

Popular Posts

Categories

AI (27) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (114) C (77) C# (12) C++ (82) Course (60) Coursera (176) coursewra (1) Cybersecurity (22) data management (11) Data Science (88) Data Strucures (6) Deep Learning (9) Django (6) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (5) flutter (1) FPL (17) Google (19) Hadoop (3) HTML&CSS (46) IBM (25) IoT (1) IS (25) Java (92) Leet Code (4) Machine Learning (44) Meta (18) MICHIGAN (5) microsoft (3) Pandas (3) PHP (20) Projects (29) Python (741) Python Coding Challenge (190) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (40) UX Research (1) web application (8)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses