This is a premium lesson. You can see the shape of every card — unlock to read them.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Variable என்பது program execution போது data/value-ஐ store செய்ய பயன்படுத்தப்படும் named m……
Premium
This card is part of the premium lesson.
Unlock
Example
int age = 25; இதில்: int → Data type age → Variable n……
Premium
This card is part of the premium lesson.
Unlock
ஒரு box-க்கு Marks என்று name வைக்கிறோம். அதற்குள்: 90 store செய்கிறோம். Later: 95 என்று change……
Premium
This card is part of the premium lesson.
Unlock
Why variable is needed
Program-ல் values temporary-ஆக store செய்ய வ……
Premium
This card is part of the premium lesson.
Unlock
Result
இதற்காக variables use செய்கிற……
Premium
This card is part of the premium lesson.
Unlock
Example
int age = 20; float salary = ……
Premium
This card is part of the premium lesson.
Unlock
Variable declaration ↓ Memory allocated ↓……
Premium
This card is part of the premium lesson.
Unlock
Example
int x = 10; Conceptually: Variable Name : x Data Type : int Value : 10 Memory : allocated……
Premium
This card is part of the premium lesson.
Unlock
Declaration
Variable-ன் name மற்றும் data type compiler-க்கு introduce ……
Premium
This card is part of the premium lesson.
Unlock
Initialization
Variable create செய்யும் நேரத்திலேயே initial value க……
Premium
This card is part of the premium lesson.
Unlock
Assignment
Already existing variable-க்க……
Premium
This card is part of the premium lesson.
Unlock
இதில்: int marks; Declaration.…
Premium
This card is part of the premium lesson.
Unlock
Practice
Assignment.
DECLARATION vs INITIALIZATION vs ASSIGNMENT இந்த difference மிகவும் imp……
Premium
This card is part of the premium lesson.
Unlock
Practice
Assignment
x = 20; Existing variable-க்க……
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
int marks = 80; Breakdown: int → Data type marks → Vari……
Premium
This card is part of the premium lesson.
Unlock
Example
Premium
This card is part of the premium lesson.
Unlock
Initially
Later
இதனால் variable name same. ஆன……
Premium
This card is part of the premium lesson.
Unlock
Program
Premium
This card is part of the premium lesson.
Unlock
Step 1
Step 2
Old value 10 replaced by 20. ……
Premium
This card is part of the premium lesson.
Unlock
Current
So
Final value: 25 VERY IMPORTAN……
Premium
This card is part of the premium lesson.
Unlock
strange equation போல இருக்கும். Programm……
Premium
This card is part of the premium lesson.
Unlock
Process: Right side first: x ……
Premium
This card is part of the premium lesson.
Unlock
Final
Variable naming rules
Variable name என்பது identifier. அதனால் identifier rules variables-க்கும் apply ஆகும். RULE 1: LETTER OR UNDE……
Premium
This card is part of the premium lesson.
Unlock
Valid variable names
age marks student1 totalMarks……
Premium
This card is part of the premium lesson.
Unlock
Invalid variable names
1age student mark total-mark ……
Premium
This card is part of the premium lesson.
Unlock
Multiple variable declaration
Same data type variables ஒரே statement-ல் d……
Premium
This card is part of the premium lesson.
Unlock
Multiple initialization
int a = 10, b = 20, c = 30;…
Premium
This card is part of the premium lesson.
Unlock
Meaning
Premium
This card is part of the premium lesson.
Unlock
Important common confusion
Consider: int a, b = 10; இதன் meaning: a → declared, ……
Premium
This card is part of the premium lesson.
Unlock
Variable with different data types
Integer variable int age = 25; Floating variable float weight = 65.5f; Double variable ……
Premium
This card is part of the premium lesson.
Unlock
Program - different variables
Premium
This card is part of the premium lesson.
Unlock
Input into variable
Example
return 0; } If user enters: 25…
Premium
This card is part of the premium lesson.
Unlock
Meaning
User enter செய்யும் value-ஐ age variable-ல் s……
Premium
This card is part of the premium lesson.
Unlock
Variable in calculation
Variables calculations-ல் use செய்……
Premium
This card is part of the premium lesson.
Unlock
Dry Run
a = 10 b = 20 sum = a + b = 1……
Premium
This card is part of the premium lesson.
Unlock
Program - addition
Premium
This card is part of the premium lesson.
Unlock
Example
int x = 100; Conceptually mem……
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Then: Variable Value x 200 Sa……
Premium
This card is part of the premium lesson.
Unlock
Memory address
Every object/variable has a m……
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Possible output
Exact address changes between……
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Simple: x → Value &x → Address of x……
Premium
This card is part of the premium lesson.
Unlock
Example
int marks = 90; marks is an identifier because it is a name. The named object represented by ……
Premium
This card is part of the premium lesson.
Unlock
Valid. Constant const int x =……
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Comparison
Premium
This card is part of the premium lesson.
Unlock
Example
int age = 25; age → Variable 25 → Literal Var……
Premium
This card is part of the premium lesson.
Unlock
Local variable
Function அல்லது block-க்குள் ……
Premium
This card is part of the premium lesson.
Unlock
Example
x is local variable. Its scop……
Premium
This card is part of the premium lesson.
Unlock
Local variable example
#include using namespace std;……
Premium
This card is part of the premium lesson.
Unlock
Global variable
Functions-க்கு வெளியே declare……
Premium
This card is part of the premium lesson.
Unlock
Example
Premium
This card is part of the premium lesson.
Unlock
return 0; } x is global variable. It can be accessibl……
Premium
This card is part of the premium lesson.
Unlock
Scope
Scope என்பது variable name progr……
Premium
This card is part of the premium lesson.
Unlock
Example
Outside
Invalid. Because x block scop……
Premium
This card is part of the premium lesson.
Unlock
Block scope
Premium
This card is part of the premium lesson.
Unlock
Example
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Local x global x-ஐ shadow செய்……
Premium
This card is part of the premium lesson.
Unlock
Here: x → Local variable ::x ……
Premium
This card is part of the premium lesson.
Unlock
Static local variable
Normally local variable function call முடிந்ததும் lifeti……
Premium
This card is part of the premium lesson.
Unlock
Example
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Normal
Every call: 1 Static: static in……
Premium
This card is part of the premium lesson.
Unlock
Auto variable
Historically, ordinary local ……
Premium
This card is part of the premium lesson.
Unlock
Example
x is an automatic local variable. Modern C++-ல் auto keyword mostly type deduction-க்கு பயன்படுத்தப்படுகிறத……
Premium
This card is part of the premium lesson.
Unlock
auto means type is automatica……
Premium
This card is part of the premium lesson.
Unlock
Example
int x; Local automatic variable x has a……
Premium
This card is part of the premium lesson.
Unlock
This can lead to undefined behavior f……
Premium
This card is part of the premium lesson.
Unlock
Practice
Initialization is good practice
Instead of: int total; Prefer when appropriate: int total = 0……
Premium
This card is part of the premium lesson.
Unlock
Different initialization styles
C++ supports multiple forms. Copy initialization int x = 10; Direct initialization int x(10); List initializa……
Premium
This card is part of the premium lesson.
Unlock
Reference variable
A reference acts as an alias fo……
Premium
This card is part of the premium lesson.
Unlock
also changes
Premium
This card is part of the premium lesson.
Unlock
Because ref refers to x.…
Premium
This card is part of the premium lesson.
Unlock
Pointer variable
Pointer variable stores another object's address. int x ……
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
*ptr accesses the value store……
Premium
This card is part of the premium lesson.
Unlock
Variable lifetime
Scope and lifetime are related but different. S……
Premium
This card is part of the premium lesson.
Unlock
Example
x normally exists during exec……
Premium
This card is part of the premium lesson.
Unlock
Common error 1
Using keyword as variable: int ……
Premium
This card is part of the premium lesson.
Unlock
Common error 2
Number at beginning: int 10ma……
Premium
This card is part of the premium lesson.
Unlock
Common error 3
Using variable before initial……
Premium
This card is part of the premium lesson.
Unlock
Common error 4
Wrong data type: int percentage = 89.……
Premium
This card is part of the premium lesson.
Unlock
Common error 5
Confusing assignment and comp……
Premium
This card is part of the premium lesson.
Unlock
Practice
Assignment
Premium
This card is part of the premium lesson.
Unlock
Comparison
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Common error 6
Expecting both variables to initialize: int a, b = ……
Premium
This card is part of the premium lesson.
Unlock
Comparison
Variable vs Identifier vs Val……
Premium
This card is part of the premium lesson.
Unlock
Example
Premium
This card is part of the premium lesson.
Unlock
A variable generally has
1. Name 2. Data type 3. Value……
Premium
This card is part of the premium lesson.
Unlock
Example
int age = 25; Name → age Type → int Value → 25……
Premium
This card is part of the premium lesson.
Unlock
V = N T V M N → Name T → Type V → Value ……
Premium
This card is part of the premium lesson.
Unlock
What is a variable? A variable is a named memory ……
Premium
This card is part of the premium lesson.
Unlock
Trb point - important
Consider: int x = 10; Identify: int ……
Premium
This card is part of the premium lesson.
Unlock
Which is a variable declarati……
Premium
This card is part of the premium lesson.
Unlock
Difference between declaration and initialization? Declaration: int ……
Premium
This card is part of the premium lesson.
Unlock
Difference between variable and constant? int……
Premium
This card is part of the premium lesson.
Unlock
Is an uninitialized local int……
Premium
This card is part of the premium lesson.
Unlock
Example
int x; A local automatic fundamental variable does not automatically become zero.……
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
Which is a valid declaration?…
Premium
This card is part of the premium lesson.
Unlock
Which statement initializes x?…
Premium
This card is part of the premium lesson.
Unlock
Which operator assigns a valu……
Premium
This card is part of the premium lesson.
Unlock
Which variable name is invali……
Premium
This card is part of the premium lesson.
Unlock
Premium
This card is part of the premium lesson.
Unlock
What is the final value? int ……
Premium
This card is part of the premium lesson.
Unlock
In: int a, b = 10; which vari……
Premium
This card is part of the premium lesson.
Unlock
Which is a local variable? in……
Premium
This card is part of the premium lesson.
Unlock
Which statement changes x fro……
Premium
This card is part of the premium lesson.
Unlock
Practice
Identify declaration, initialization, assignment: int x; x = 10; int y = 20; x ……
Premium
This card is part of the premium lesson.
Unlock
Dry Run
Practice - dry run
Variable A variable is a named memory locat……
Premium
This card is part of the premium lesson.
Unlock
Syntax
data_type variable_name; int a……
Premium
This card is part of the premium lesson.
Unlock
Main concepts: Declaration → int x; Initialization → int x = 10; Assignment → x = 20; Important d……
Premium
This card is part of the premium lesson.
Unlock