0% found this document useful (0 votes)
7 views18 pages

CT Variables

The document provides an overview of variables in programming, detailing their purpose as data storage that can change based on program conditions. It outlines the syntax for declaring variables, the different data types and their memory usage, and rules for naming variables. Additionally, it explains the concepts of initializing variables, constant variables, variable scope, and the distinction between global and local variables.

Uploaded by

bhemoquialda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views18 pages

CT Variables

The document provides an overview of variables in programming, detailing their purpose as data storage that can change based on program conditions. It outlines the syntax for declaring variables, the different data types and their memory usage, and rules for naming variables. Additionally, it explains the concepts of initializing variables, constant variables, variable scope, and the distinction between global and local variables.

Uploaded by

bhemoquialda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Variables

Variables
• Serves as data storage for the
assigned or calculated value in your
program.
• The value it holds may vary or change
depending on the conditions or
instructions specified in the program
• It requires a data type to identify the
kind of data to be stored and a
variable name.
Variables
• Syntax
dataype variableName;
Data type of a Variable
Data Type Description Arduino
Ram Usage

boolean Holds true or false value 1 byte

char Stores a character value 1 byte

Primary data type for a whole number storage


int 4 bytes
commonly in 16 bits (2 bytes)

float Stores number with floating or decimal point 4 bytes


Rules in naming a
variable
Rules in naming a variable
1. The first character of a variable
name must be a letter either
uppercase and lowercase followed
by a combination of any letters
and numbers. An underscore is the
only acceptable special character.
Rules in naming a variable

2. The use of an underscore to


start a variable is not
recommended since it might
conflict with the computer system
name and cause an error.
Rules in naming a variable

3. A variable name can be of any


length, though the compiler only
checks the first 31 characters of a
variable.
Initializing Variables
Initializing Variables

Initializing a variable means to


assign a starting value to a variable
during declaration or within the
program.
Initializing Variables
Assignment operator will be used to
assign a specific value to be stored in
that variable.

Assignment operator “=“


Constant Variables

Variables that do not and must not


change their value throughout the
program.
Multiple Variables Declaration

Variable declaration can be


separated by a comma(,).
Variable Scope
The scope of a variable refers to the
visibility or accessibility of the
variable within the program.

The part where you declare the


variable may identify the scope of
the variable.
Variable Scope
The scope of a variable refers to the
visibility or accessibility of the
variable within the program.

The part where you declare the


variable may identify the scope of
the variable.
Variable Scope
The scope of a variable refers to the
visibility or accessibility of the
variable within the program.

The part where you declare the


variable may identify the scope of
the variable.
Global Variables
Variables defined at the topmost part
of your program to declare it outside
all function are called global
variables.
These variables can be used and are
accessible to all functions in the
entire program.
Local variables

They are only declared inside the


block of a specific function.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy