Variables vs Constants - Deepstash
Variables vs Constants

Variables vs Constants

Curated from: mobile.twitter.com

Ideas, facts & insights covering these topics:

9 ideas

·

203 reads

4

Explore the World's Best Ideas

Join today and uncover 100+ curated journeys from 50+ topics. Unlock access to our mobile app with extensive features.

Variables vs Constants

Variables vs Constants

Variables and Constants are mostly misunderstood in programming. Most of the time, most of the people read bad definitions on Constants. A thread on this.

8

83 reads

First of all, we need to understand the usage of both variables and constants. Variables are used to store values which can be changed in run time whereas constant cannot be changed.

{1/9}

8

20 reads

But some of the websites/people explain these two in the wrong way. Mostly the definition for constant would be "A constant is a variable that can't be changed in the program".

{2/9}

8

24 reads

It totally makes no sense. This statement states that a CONSTANT is a VARIABLE but it's value can't be changed. If CONSTANT is a VARIABLE then the value can be changed. A total collapse in the meaning.

{3/9}

8

12 reads

So, both "Variable" and "Constant" come under a concept called "Identifiers". As the name suggests, identifiers help us to identify a value which is stored in the memory with the help of a name. It's like a box which contains some values/information with a label attached.

{4/9}

8

11 reads

Say if you wanna store a number "42" in your program/code, you can assign it to an identifier. So that you can use it later in your program.

{5/9}

8

11 reads

If a value stored in an identifier which can be changed in the run time, it is called a "Variable". If it cannot be changed it is called a "Constant".

{6/9}

8

11 reads

<p>Values stored in memory can...

Values stored in memory can't be accessed without knowing the address. Since we can't remember addresses, we need some kind of label which points to that address. Something like a contact number saved in the phone. We can’t remember phone numbers, but we can remember names.

{8/9}

8

13 reads

Also Also identifiers can be function names, type names, class names, labels, etc.,can be function names, type names, class names, labels, etc.,

{9/9}

8

18 reads

IDEAS CURATED BY

djhemath

A self-taught software developer, obsessed with product ideas. I love to sleep, travel, make music and meeting people in person.

DJ Hemath's ideas are part of this journey:

Machine Learning With Google

Learn more about computerscience with this collection

Understanding machine learning models

Improving data analysis and decision-making

How Google uses logic in machine learning

Related collections

Read & Learn

20x Faster

without
deepstash

with
deepstash

with

deepstash

Personalized microlearning

—

100+ Learning Journeys

—

Access to 200,000+ ideas

—

Access to the mobile app

—

Unlimited idea saving

—

—

Unlimited history

—

—

Unlimited listening to ideas

—

—

Downloading & offline access

—

—

Supercharge your mind with one idea per day

Enter your email and spend 1 minute every day to learn something new.

Email

I agree to receive email updates