SlideShare a Scribd company logo
2
Most read
8
Most read
9
Most read
Constants and Variables in
C programming
Chitrank Dixit
Constants
Any unchanged value in a program during the program
execution is called constant. Following are the constants in C
language.
• Numeric Constants
• String or Character Constants.
Numeric Constants
• Integer Constant
– An integer constant is a signed or unsigned whole
number.
– Example: -23 +356 46
– C language supports an integer constant in octal
(base 8) , decimal (base 10) and hexadecimal
(base 16). The default number system followed in
C language is decimal (base 10).
– An octal number is preceded by zero (0) and a
hexadecimal number is preceded by 0x or 0X.
• Real or floating point constant:
– Any signed or unsigned number with fractional
part is called real or floating point constant. A real
constant can be written in decimal or exponential
form.
– Example
– Decimal Form 0.254 +342.0 -
3.15
– Exponential Form 0.218e6 0.42e-32 -
1.0e12
– (0.218e6 means --> 0.218 x 10^6 and so on for all)
String or Character Constants
• Any string of characters enclosed in apostrophes or
quotes is called string constant or character constant.
There are two types of string constants.
• Single Character String Constant
• String of Characters Constant
Single Character String Constant
• Any letter or character enclosed in single apostrophe
is called single character string constant.
– Example: 'y' '$' '+'
String of Characters Constant
• Any string of characters consisting of letters, digits
and symbols enclosed in double quotes is called
string of characters constant.
– Example:
– "Total value is“ , “12 vyas fala”, “value is = “
Variables
• A variable is an identifier or a name which is used to
refer a value and this value varies or changes during
the program execution. A variable is written with a
combination of letters , numbers and special
characters _(underscore) with the first letter being
an alphabet. Maximum of 31 letters can be used to
write a variable.
– Example: x , fact , c22 , total_value
Important rules while writing a
variable in C Programming
• Upper and Lower case alphabets are taken differently, so
the variables SUM and sum are referring to different
values.
• No special characters other than underscore ( _ ) are
permitted.
• Some C compilers will not accept more than 8 characters.
So it is a good practice writing a variable with few letters
which makes it also convenient to write and use
• All variables used in a C program are declared with
appropriate data types before the variable is assigned any
value.
• Reserved words cannot be used as variables.

More Related Content

What's hot (20)

PPTX
Data Types and Variables In C Programming
Kamal Acharya
 
PPTX
data types in C programming
Harshita Yadav
 
PPTX
Data Type in C Programming
Qazi Shahzad Ali
 
PPT
constants, variables and datatypes in C
Sahithi Naraparaju
 
PPTX
Data types
Nokesh Prabhakar
 
PPTX
Data types in C
Tarun Sharma
 
PPTX
C language ppt
Ğäùråv Júñêjå
 
PPT
Introduction to c programming
ABHISHEK fulwadhwa
 
PPTX
Presentation on C Switch Case Statements
Dipesh Panday
 
PPTX
Programming flowcharts for C Language
Aryan Ajmer
 
PPT
C by balaguruswami - e.balagurusamy
Srichandan Sobhanayak
 
PPTX
C tokens
Manu1325
 
PDF
Introduction to c++ ppt 1
Prof. Dr. K. Adisesha
 
PPTX
Expression and Operartor In C Programming
Kamal Acharya
 
PPT
Constants in C Programming
programming9
 
PPTX
The Loops
Krishma Parekh
 
PPTX
Function in C program
Nurul Zakiah Zamri Tan
 
PPT
Strings
Mitali Chugh
 
PPTX
Variables in C++, data types in c++
Neeru Mittal
 
PPTX
Functions in C
Kamal Acharya
 
Data Types and Variables In C Programming
Kamal Acharya
 
data types in C programming
Harshita Yadav
 
Data Type in C Programming
Qazi Shahzad Ali
 
constants, variables and datatypes in C
Sahithi Naraparaju
 
Data types
Nokesh Prabhakar
 
Data types in C
Tarun Sharma
 
C language ppt
Ğäùråv Júñêjå
 
Introduction to c programming
ABHISHEK fulwadhwa
 
Presentation on C Switch Case Statements
Dipesh Panday
 
Programming flowcharts for C Language
Aryan Ajmer
 
C by balaguruswami - e.balagurusamy
Srichandan Sobhanayak
 
C tokens
Manu1325
 
Introduction to c++ ppt 1
Prof. Dr. K. Adisesha
 
Expression and Operartor In C Programming
Kamal Acharya
 
Constants in C Programming
programming9
 
The Loops
Krishma Parekh
 
Function in C program
Nurul Zakiah Zamri Tan
 
Strings
Mitali Chugh
 
Variables in C++, data types in c++
Neeru Mittal
 
Functions in C
Kamal Acharya
 

Viewers also liked (9)

PPTX
Presentation on literature review
Karna Bahadur Chongbang
 
PPTX
The Literature Review Process
annielibrarian
 
PPTX
Concept, Construct and Variable
Dr. Anamika Ray Memorial Trust
 
PPT
The research instruments
Yolanda Sobrepena
 
PPTX
Ethical issues in research
R.Harish Kumar
 
PPTX
Educational research
meenuch
 
PDF
Literature Review
Anaika Alexander
 
PPTX
Characteristics and criteria of good research
A B
 
PPSX
Literature review in research
Nursing Path
 
Presentation on literature review
Karna Bahadur Chongbang
 
The Literature Review Process
annielibrarian
 
Concept, Construct and Variable
Dr. Anamika Ray Memorial Trust
 
The research instruments
Yolanda Sobrepena
 
Ethical issues in research
R.Harish Kumar
 
Educational research
meenuch
 
Literature Review
Anaika Alexander
 
Characteristics and criteria of good research
A B
 
Literature review in research
Nursing Path
 
Ad

Similar to Constants and variables in c programming (20)

PDF
Learning c - An extensive guide to learn the C Language
Abhishek Dwivedi
 
PDF
Lecture 4 constants_variables
eShikshak
 
DOCX
C programming tutorial
Mohit Saini
 
PPTX
Introduction to C language programming.pptx
OVIDMAMAH
 
PDF
Constants Variables Datatypes by Mrs. Sowmya Jyothi
SowmyaJyothi3
 
PPTX
Constant and variacles in c
yash patel
 
PDF
Basic of the C language
Sachin Verma
 
PDF
[ITP - Lecture 04] Variables and Constants in C/C++
Muhammad Hammad Waseem
 
PDF
PSPC--UNIT-2.pdf
ArshiniGubbala3
 
PPTX
C Programming Lecture 3 - Elements of C.pptx
Murali M
 
PPSX
Programming in c
vineet4523
 
DOCX
C basics by haseeb khan
Haseeb Shalmani
 
PPT
C presentation book
krunal1210
 
PPT
Intro Basics of C language Operators.ppt
SushJalai
 
PPT
Basics of C.ppt
SeethaDinesh
 
PPT
Basics of c
vinothini1996
 
PPT
Basics of C.ppt
ssuserc8fc691
 
PPT
Basics of C.ppt
MITSINDHAV2
 
PPT
Basics of C.ppt
ChiranjeevivarmaP
 
PPT
Basics of C.ppt
TanuGohel
 
Learning c - An extensive guide to learn the C Language
Abhishek Dwivedi
 
Lecture 4 constants_variables
eShikshak
 
C programming tutorial
Mohit Saini
 
Introduction to C language programming.pptx
OVIDMAMAH
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
SowmyaJyothi3
 
Constant and variacles in c
yash patel
 
Basic of the C language
Sachin Verma
 
[ITP - Lecture 04] Variables and Constants in C/C++
Muhammad Hammad Waseem
 
PSPC--UNIT-2.pdf
ArshiniGubbala3
 
C Programming Lecture 3 - Elements of C.pptx
Murali M
 
Programming in c
vineet4523
 
C basics by haseeb khan
Haseeb Shalmani
 
C presentation book
krunal1210
 
Intro Basics of C language Operators.ppt
SushJalai
 
Basics of C.ppt
SeethaDinesh
 
Basics of c
vinothini1996
 
Basics of C.ppt
ssuserc8fc691
 
Basics of C.ppt
MITSINDHAV2
 
Basics of C.ppt
ChiranjeevivarmaP
 
Basics of C.ppt
TanuGohel
 
Ad

Recently uploaded (20)

PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PDF
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 

Constants and variables in c programming

  • 1. Constants and Variables in C programming Chitrank Dixit
  • 2. Constants Any unchanged value in a program during the program execution is called constant. Following are the constants in C language. • Numeric Constants • String or Character Constants.
  • 3. Numeric Constants • Integer Constant – An integer constant is a signed or unsigned whole number. – Example: -23 +356 46 – C language supports an integer constant in octal (base 8) , decimal (base 10) and hexadecimal (base 16). The default number system followed in C language is decimal (base 10). – An octal number is preceded by zero (0) and a hexadecimal number is preceded by 0x or 0X.
  • 4. • Real or floating point constant: – Any signed or unsigned number with fractional part is called real or floating point constant. A real constant can be written in decimal or exponential form. – Example – Decimal Form 0.254 +342.0 - 3.15 – Exponential Form 0.218e6 0.42e-32 - 1.0e12 – (0.218e6 means --> 0.218 x 10^6 and so on for all)
  • 5. String or Character Constants • Any string of characters enclosed in apostrophes or quotes is called string constant or character constant. There are two types of string constants. • Single Character String Constant • String of Characters Constant
  • 6. Single Character String Constant • Any letter or character enclosed in single apostrophe is called single character string constant. – Example: 'y' '$' '+'
  • 7. String of Characters Constant • Any string of characters consisting of letters, digits and symbols enclosed in double quotes is called string of characters constant. – Example: – "Total value is“ , “12 vyas fala”, “value is = “
  • 8. Variables • A variable is an identifier or a name which is used to refer a value and this value varies or changes during the program execution. A variable is written with a combination of letters , numbers and special characters _(underscore) with the first letter being an alphabet. Maximum of 31 letters can be used to write a variable. – Example: x , fact , c22 , total_value
  • 9. Important rules while writing a variable in C Programming • Upper and Lower case alphabets are taken differently, so the variables SUM and sum are referring to different values. • No special characters other than underscore ( _ ) are permitted. • Some C compilers will not accept more than 8 characters. So it is a good practice writing a variable with few letters which makes it also convenient to write and use • All variables used in a C program are declared with appropriate data types before the variable is assigned any value. • Reserved words cannot be used as variables.