SlideShare a Scribd company logo
1 of 6
WHAT IS A VARIABLE?
In Mathematics, A variable is some letter which
hold some value, Like x=20. A variable’s value will
vary(change) accordingly. Variables are used in
expressions and equations.
WHAT IS A VARIABLE?
In Programming, A variable is a named memory
location which holds input data and its computational
results. E.g. marks = 97. It is same like a box that you
label and put some stuff into.
CHARACTERISTICS OF A VARIABLE?
Variables are created in RAM, So data stored in
Variables is temporary
VARIABLE DECLARATION
Writing variable name with its data type is called Variable
declaration. It tells the compiler the name of the variable
to be used in program and type of information to be stored
in it
Syntax:
Data Type Variable Name;
Example:
int marks;
float height;
char x;
int x,y,z,a,age;
C is a strongly typed language, so all variables must be
declared before being used. The compiler will report error if an
undeclared variable is used in a program.
VARIABLE INITIALIZATION
Assigning a value first time after Variable declaration is
called variable initialization
Syntax:
Data Type Variable Name = value;
Example:
int marks = 99;
float height;
height = 170;
RULES FOR FOR NAMING A VARIABLE
Variable name in C consists of letters, numbers, or
an underscore.
First character of a variable should be a letter or
underscore(_).
Keywords can not be used for variable names like
int, void etc.
Blank space between variable names is not allowed.
Constant
A constant is an identifier whose value cannot be changed
during program execution. E.g. PI

More Related Content

Similar to What is a Variable in C Language? | Variable Declaration and initialization.pptx

C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
Abhinav Vatsa
 
C++ PROGRAMMING BASICS
C++ PROGRAMMING BASICSC++ PROGRAMMING BASICS
C++ PROGRAMMING BASICS
Aami Kakakhel
 
Introduction to Computer and Programming - Lecture 03
Introduction to Computer and Programming - Lecture 03Introduction to Computer and Programming - Lecture 03
Introduction to Computer and Programming - Lecture 03
hassaanciit
 
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdfL2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
MMRF2
 

Similar to What is a Variable in C Language? | Variable Declaration and initialization.pptx (20)

Basic of java 2
Basic of java  2Basic of java  2
Basic of java 2
 
Variables and calculations_chpt_4
Variables and calculations_chpt_4Variables and calculations_chpt_4
Variables and calculations_chpt_4
 
Lec-2- Ehsjdjkck. Jdkdbd djskrogramming.pdf
Lec-2- Ehsjdjkck. Jdkdbd djskrogramming.pdfLec-2- Ehsjdjkck. Jdkdbd djskrogramming.pdf
Lec-2- Ehsjdjkck. Jdkdbd djskrogramming.pdf
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptx
 
Data Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# ProgrammingData Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# Programming
 
VARIABLE AND DATATYPES-JAVA.pptx
VARIABLE AND DATATYPES-JAVA.pptxVARIABLE AND DATATYPES-JAVA.pptx
VARIABLE AND DATATYPES-JAVA.pptx
 
Unit 2- Module 2.pptx
Unit 2- Module 2.pptxUnit 2- Module 2.pptx
Unit 2- Module 2.pptx
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data Types
 
R Programming: Variable
R Programming: VariableR Programming: Variable
R Programming: Variable
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
 
C
CC
C
 
C++ PROGRAMMING BASICS
C++ PROGRAMMING BASICSC++ PROGRAMMING BASICS
C++ PROGRAMMING BASICS
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE
 
Basic
BasicBasic
Basic
 
Introduction to Computer and Programming - Lecture 03
Introduction to Computer and Programming - Lecture 03Introduction to Computer and Programming - Lecture 03
Introduction to Computer and Programming - Lecture 03
 
history of c.ppt
history of c.ppthistory of c.ppt
history of c.ppt
 
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdfL2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
 
Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4
 
Compiler Construction.pptx
Compiler Construction.pptxCompiler Construction.pptx
Compiler Construction.pptx
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

What is a Variable in C Language? | Variable Declaration and initialization.pptx

  • 1. WHAT IS A VARIABLE? In Mathematics, A variable is some letter which hold some value, Like x=20. A variable’s value will vary(change) accordingly. Variables are used in expressions and equations.
  • 2. WHAT IS A VARIABLE? In Programming, A variable is a named memory location which holds input data and its computational results. E.g. marks = 97. It is same like a box that you label and put some stuff into.
  • 3. CHARACTERISTICS OF A VARIABLE? Variables are created in RAM, So data stored in Variables is temporary VARIABLE DECLARATION Writing variable name with its data type is called Variable declaration. It tells the compiler the name of the variable to be used in program and type of information to be stored in it Syntax: Data Type Variable Name; Example: int marks; float height; char x; int x,y,z,a,age; C is a strongly typed language, so all variables must be declared before being used. The compiler will report error if an undeclared variable is used in a program.
  • 4. VARIABLE INITIALIZATION Assigning a value first time after Variable declaration is called variable initialization Syntax: Data Type Variable Name = value; Example: int marks = 99; float height; height = 170;
  • 5. RULES FOR FOR NAMING A VARIABLE Variable name in C consists of letters, numbers, or an underscore. First character of a variable should be a letter or underscore(_). Keywords can not be used for variable names like int, void etc. Blank space between variable names is not allowed.
  • 6. Constant A constant is an identifier whose value cannot be changed during program execution. E.g. PI