GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • C programming
  • C++ programming
  • Java programming
  • Python programming
  • HTML
  • CSS
  • Codenora IDE (opens in a new tab)
  • About us
  • Pricing
  • Contact us
  • Privacy policy
  • Terms of service
  • Refund and Cancellation

This view

  • Original page
  • New address

GeezerVison is showing www.dremendo.com — Variable in C++ Programming with Example | Dremendo

  • Dremendo
  • C
  • C++
  • Java
  • Python
  • HTML
  • CSS
  • More
    • Home
    • C Tutorial
    • C++ Tutorial
    • Java Tutorial
    • Python Tutorial
    • HTML Tutorial
    • CSS Tutorial
?>
profile image
Announcements
No new announcements.
mentora icon
C++ Programming Tutorial
  • C++ Basic Concepts
    • Introduction
    • Variable
    • Data Types and Modifiers
    • Naming Conventions
    • Integer Variable
    • Float and Double Variables
    • Character Variable
    • Boolean Variable
    • Constant Variable
    • Typecasting
  • Operators in C++
    • Operators
    • Assignment Operators
    • Arithmetic Operators
    • Relational Operators
    • Logical Operators
    • Operator Precedence
  • Input and Output in C++
    • Environment Setup
    • Program Basic Structure
    • cout Statement
    • cin Statement
    • Comments
  • Decision Making in C++
    • Decision Making
    • if Statement
    • if else Statement
    • if else if Statement
    • Conditional Operator
    • switch case Statement
  • Mathematical Functions
    • Mathematical Functions
  • Loops in C++
    • What are Loops
    • for Loop
    • while Loop
    • do while Loop
  • Arrays in C++
    • One Dimensional Array
    • Two Dimensional Array
  • String in C++
    • C-Style String
    • C-Style String Methods
    • String
    • String Methods
  • Searching in C++
    • Linear Search
    • Binary Search
  • Sorting in C++
    • Bubble Sort
    • Selection Sort
    • Insertion Sort
  • Pointer in C++
    • Pointer
    • Dynamic Memory Allocation
    • References
  • User Defined Datatype in C++
    • Structure
    • Union
    • Enum
  • Function in C++
    • Function
    • Recursive Function
    • Function Overloading
    • Storage Classes
    • User-Defined Header Files
  • Data Structures in C++
    • Stack
    • Queue
    • Circular Queue
    • Double Ended Queue
    • Singly Linked List
    • Doubly Linked List
    • Stack using Linked List
    • Queue using Linked List
  • OOPs in C++
    • Classes and Objects
    • Instance Variables
    • Instance Methods
    • Access Specifiers
    • Constructor
    • Destructor
    • Static Variables
    • Static Methods
    • Friend Function
    • Friend Class
    • Inheritance
    • Types of Inheritance
    • Polymorphism
    • Abstract Class
  • File Handling in C++
    • Text File Handling
    • Binary File Handling

bookmark
Table of Contents

    Variable in C++ Programming with Example

    In this lesson, we will learn about the variable in C++ programming and its application, along with an example.

    What is Variable

    A variable is like a container that stores information which can be used and manipulated by a program. Variables have names, and these names are used to access the stored data.

    Think variable as a box having a name where you can keep a piece of data that you can use later in your program. You can also change the data stored in a variable whenever you want.

    Video Explanation

    Click the button below to watch the explanation.

    Please wait while the video is loading....
    video image

    A variable has three key concept and they are:

    • Name: This is the label you give to the variable.
    • Value: This is the information you want to store in the variable.
    • Data Type: This indicates what kind of data the variable is holding (e.g., a number, text, etc.). We will discuss about it in our next lesson.

    Let's see some real-life examples of variables. Image you are organizing a birthday party and need to keep track of various details. So let's see how you can store those details in variables.

    You need to store the total number of guest coming to the party.

    You can use Variable Name: guest_count and store the value 20 in it like.

    guest_count = 20


    You need to store the name of the person whose birthday it is.

    birthday_person = "Alice"


    You need to remember the date of the party.

    party_date = "2024-06-15"


    You need to keep track of how much money you have for the party.

    budget = 5000.00


    You need to know if the party will be held indoors.

    is_indoors = True

    Let's take another Example

    Example
    a = 5
    a = 25

    In the above example, a is used as a variable name to store the value 5 in it. So we can say that the value of the variable a is 5.

    On the second line we have changed the value of the variable a by storing a new value 25 in it. Now the new value of variable a is 25.

    So it is clear from the above example that a variable can store only one value at a time if you store any other value in it then the previous value will be erased and the new value will be stored in it.

    Test Your Knowledge

    Attempt the questions in the exercise to check whether you have understood the lesson clearly.

    Exercise
    Test Your Knowledge
    Previous Next

    We care about your privacy

    Dremendo uses cookies and similar technologies that are necessary for the site to work properly, understand how you interact with our website, and measure the effectiveness of our marketing. By clicking Accept All, you consent to the use of non-essential cookies and similar technologies for analytics, advertising, and ad measurement, as described in our Privacy Policy.

    Cookie Preferences

    Choose which types of cookies Dremendo may use.

    Necessary Cookies

    Required for essential website functionality and security.

    Allow
    Analytics Cookies

    Help us understand how visitors use Dremendo.

    Allow
    Marketing Cookies

    Help us measure advertising performance and understand interactions with our advertisements.

    Allow
    Mentora Question Asked: 0 / 20

    Hi, I’m Mentora!

    I’m your personal AI tutor from Dremendo. Ask me anything, and I’ll help you understand it in a simple and easy way.

    You are visitor 01402520 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.