logo CBCE Skill INDIA

Welcome to CBCE Skill INDIA. An ISO 9001:2015 Certified Autonomous Body | Best Quality Computer and Skills Training Provider Organization. Established Under Indian Trust Act 1882, Govt. of India. Identity No. - IV-190200628, and registered under NITI Aayog Govt. of India. Identity No. - WB/2023/0344555. Also registered under Ministry of Micro, Small & Medium Enterprises - MSME (Govt. of India). Registration Number - UDYAM-WB-06-0031863

What are the 5 types of variables?


5 Types of Variables

The term "types of variables" can be interpreted in different ways, so I'll provide explanations for two possible interpretations:

 

1. Types of Variables Based on Scope:

  1. Local Variable:

    • A variable defined within a function or a block of code. It is only accessible within that specific function or block.
  2. Global Variable:

    • A variable defined outside of any function or block. It is accessible from anywhere in the script.
  3. Static Variable:

    • A variable declared within a function but retains its value between multiple calls to that function. It maintains its value across function calls.

 

2. Types of Variables Based on Data:

  1. Integer Variable:

    • A variable that holds whole numbers without a decimal point.
  2. Float Variable:

    • A variable that holds numbers with decimal points or in exponential form (floating-point numbers).
  3. String Variable:

    • A variable that holds a sequence of characters.
  4. Boolean Variable:

    • A variable that holds a truth value, either true or false.
  5. Array Variable:

    • A variable that can hold multiple values. It can be indexed (numerically or associatively) or multidimensional.

 

These classifications provide an overview of the different aspects of variables in programming. It's important to note that the concept of "types of variables" might be approached differently depending on the context, and these categories are just one way to categorize variables. In some cases, people might refer to types of variables based on their purpose, such as input variables, output variables, etc.

 

Thank you.


Give us your feedback!

Your email address will not be published. Required fields are marked *
0 Comments Write Comment