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

100 Python Programs for Beginner (53) AI (34) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (173) C (77) C# (12) C++ (82) Course (67) Coursera (226) Cybersecurity (24) data management (11) Data Science (128) Data Strucures (8) Deep Learning (20) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (34) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (59) Meta (22) MICHIGAN (5) microsoft (4) Nvidia (3) Pandas (4) PHP (20) Projects (29) Python (932) Python Coding Challenge (358) Python Quiz (23) Python Tips (2) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (3) Software (17) SQL (42) UX Research (1) web application (8) Web development (2) web scraping (2)

Followers

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