SlideShare a Scribd company logo
Constants in ‘C’
By:SatveerKaur,AssistantProfessor,KhalsaCollege,Patiala.
1
Constant
Refer to fixed values.
Values do not change during the execution of a
program.
Uses the secondary storage area.
For every language, constants are same.
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala.
2
Types of Constant
Constant
Numeric
constant
Integer
constant
Real constant
Character
constant
Single character
constant
String constant
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala.
3
Numeric constant
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala.
4
Have numeric value having a combination of sequence of digits.
0-9 as alone digits or combination of 0-9 with or without decimal point.
Integer numeric constant
Decimal integer
Octal integer
Hexadecimal integer
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala.
5
Integer numeric constant
Decimal integer
•A set of digits 0-9, preceded by an optional – or + sign.
•Embedded spaces, commas, non-digit characters are not permitted between digits.
•Examples are 123, -321, 0 , 654321, +78
Octal integer
•Consist of any combination of digits 0-7, with a leading 0.
•Examples are 037, 0, 0435, 0551
Hexadecimal
Integer
•Sequence of digits preceded by 0x or 0X.
•Also include alphabets A through F or a through f representing numbers 10-15.
•Examples are 0x2, 0X9F, oxbcd, 0X.
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala.
6
Range of integer constants
Generally it is machine dependent for largest integer value.
On 16-bit machines, it is 32767.
On 32-bit machines, it is 2,147,483,647.
Also possible to store larger integer constants by appending qualifiers like U, L and UL.
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala.
7
Examples:
Unsigned integer
Unsigned long integer
Long integer
• 56789U
• 56789u
• 985674213UL
• 985674213ul
• 9876543L
• 9876543l
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala.
8
Real Constant
Real
constants
Are represented by numbers containing fractional parts like 15.456
Are shown in decimal notation, having a whole number followed by a decimal point and the fractional point.
Possible to omit digits before or after the decimal points e.g. 215. , .95 , -.72 , +.5
May also be expressed in exponential(or scientific) notation. General form is mantissa e exponent
Example is 215.65 may be written as 2.1565e2
e2 means multiply by 102
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala.
9
Real Constants
Real
constants
Mantissa is either a real number represented in decimal notation or an integer.
Exponent is an integer number with an optional plus or minus sign.
Letter e separating the mantissa and the exponent can be written inn uppercase or lowercase.
Embedded white space is not allowed.
Are useful for very large or very small numbers e.g. 9500000000 may be written as 9.5E9 or 95E8 and -0.000000348 be
as -3.48E-7
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala.
10
Single character constant
Contains a single character enclosed in single quote marks e.g. ‘5’
, ‘X’.
Character constant is not the same as the numbers.
Have integer values known as ASCII values e.g. ‘a’ have 97 as its
ASCII value..
Also possible to perform arithmetic operations on character
constants.
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala.
11
String constants
A sequence of characters enclosed in double quotes.
Characters may be letters, numbers, special characters,
and blank spaces e.g. “Hello”, “1987”
Single character string is not equivalent to a character
constant and does not have an equivalent integer value.
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala.
12
THANK YOU
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala.
13

More Related Content

What's hot

Translating Mathematical Phrases into Algebraic Expressions or Equations
Translating Mathematical Phrases into Algebraic Expressions or EquationsTranslating Mathematical Phrases into Algebraic Expressions or Equations
Translating Mathematical Phrases into Algebraic Expressions or Equations
Sonarin Cruz
 
1.1 and 1.2
1.1 and 1.21.1 and 1.2
1.1 and 1.2
leblance
 
Operators and expressons
Operators and expressonsOperators and expressons
Operators and expressons
Satveer Mann
 
7 2
7 27 2
Differential Equation SlideShare by Kamran Zafar
Differential Equation SlideShare by Kamran ZafarDifferential Equation SlideShare by Kamran Zafar
Differential Equation SlideShare by Kamran Zafar
Kamran Zafar
 
Module For Mathematics
Module For Mathematics Module For Mathematics
Module For Mathematics
jrbt2014
 
Participation Constraints in ER diagram
Participation Constraints in ER diagramParticipation Constraints in ER diagram
Participation Constraints in ER diagram
Megha Sharma
 
9.2 rational and irrational numbers day 1
9.2 rational and irrational numbers day 19.2 rational and irrational numbers day 1
9.2 rational and irrational numbers day 1
bweldon
 
3.1 tuple relational_calculus
3.1 tuple relational_calculus3.1 tuple relational_calculus
3.1 tuple relational_calculus
Utkarsh De
 
Operators in c
Operators in cOperators in c
Operators in c
Milap Bhanderi
 
Addition of integers Grade 6
Addition of integers Grade 6Addition of integers Grade 6
Addition of integers Grade 6
jona0616
 
3 relational model
3 relational model3 relational model
3 relational model
Utkarsh De
 
2 entity relationship_model
2 entity relationship_model2 entity relationship_model
2 entity relationship_model
Utkarsh De
 
Scaffold reading presentation.Slideshow
Scaffold reading presentation.SlideshowScaffold reading presentation.Slideshow
Scaffold reading presentation.Slideshow
Touché Tanner
 
Scaffold reading presentation
Scaffold reading presentationScaffold reading presentation
Scaffold reading presentation
Touché Tanner
 
Adding gift questions in swayam 2.0
Adding gift questions  in swayam 2.0Adding gift questions  in swayam 2.0
Adding gift questions in swayam 2.0
aschrdc
 
Rational numbers
Rational numbersRational numbers
Rational numbers
Pooja M
 

What's hot (17)

Translating Mathematical Phrases into Algebraic Expressions or Equations
Translating Mathematical Phrases into Algebraic Expressions or EquationsTranslating Mathematical Phrases into Algebraic Expressions or Equations
Translating Mathematical Phrases into Algebraic Expressions or Equations
 
1.1 and 1.2
1.1 and 1.21.1 and 1.2
1.1 and 1.2
 
Operators and expressons
Operators and expressonsOperators and expressons
Operators and expressons
 
7 2
7 27 2
7 2
 
Differential Equation SlideShare by Kamran Zafar
Differential Equation SlideShare by Kamran ZafarDifferential Equation SlideShare by Kamran Zafar
Differential Equation SlideShare by Kamran Zafar
 
Module For Mathematics
Module For Mathematics Module For Mathematics
Module For Mathematics
 
Participation Constraints in ER diagram
Participation Constraints in ER diagramParticipation Constraints in ER diagram
Participation Constraints in ER diagram
 
9.2 rational and irrational numbers day 1
9.2 rational and irrational numbers day 19.2 rational and irrational numbers day 1
9.2 rational and irrational numbers day 1
 
3.1 tuple relational_calculus
3.1 tuple relational_calculus3.1 tuple relational_calculus
3.1 tuple relational_calculus
 
Operators in c
Operators in cOperators in c
Operators in c
 
Addition of integers Grade 6
Addition of integers Grade 6Addition of integers Grade 6
Addition of integers Grade 6
 
3 relational model
3 relational model3 relational model
3 relational model
 
2 entity relationship_model
2 entity relationship_model2 entity relationship_model
2 entity relationship_model
 
Scaffold reading presentation.Slideshow
Scaffold reading presentation.SlideshowScaffold reading presentation.Slideshow
Scaffold reading presentation.Slideshow
 
Scaffold reading presentation
Scaffold reading presentationScaffold reading presentation
Scaffold reading presentation
 
Adding gift questions in swayam 2.0
Adding gift questions  in swayam 2.0Adding gift questions  in swayam 2.0
Adding gift questions in swayam 2.0
 
Rational numbers
Rational numbersRational numbers
Rational numbers
 

Similar to Constants in C

Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
Kamal Acharya
 
COM1407: Variables and Data Types
COM1407: Variables and Data Types COM1407: Variables and Data Types
COM1407: Variables and Data Types
Hemantha Kulathilake
 
Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programming
Chitrank Dixit
 
PROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptxPROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptx
Nithya K
 
Introduction
IntroductionIntroduction
Introduction
Komal Pardeshi
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
Ch08
Ch08Ch08
Variables in C
Variables in CVariables in C
Variables in C
Satveer Mann
 
Central tedency
Central tedencyCentral tedency
Central tedency
DAndraGreen
 
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
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
SowmyaJyothi3
 

Similar to Constants in C (11)

Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
COM1407: Variables and Data Types
COM1407: Variables and Data Types COM1407: Variables and Data Types
COM1407: Variables and Data Types
 
Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programming
 
PROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptxPROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptx
 
Introduction
IntroductionIntroduction
Introduction
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Ch08
Ch08Ch08
Ch08
 
Variables in C
Variables in CVariables in C
Variables in C
 
Central tedency
Central tedencyCentral tedency
Central tedency
 
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
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
 

More from Satveer Mann

Data types in C
Data types in CData types in C
Data types in C
Satveer Mann
 
keywords and identifiers
 keywords and identifiers keywords and identifiers
keywords and identifiers
Satveer Mann
 
Preprocessor directives
Preprocessor directivesPreprocessor directives
Preprocessor directives
Satveer Mann
 
Program structure of c
Program structure of cProgram structure of c
Program structure of c
Satveer Mann
 
Algorithms, flow charts and pseudocodes
Algorithms, flow charts and pseudocodesAlgorithms, flow charts and pseudocodes
Algorithms, flow charts and pseudocodes
Satveer Mann
 
Problem solving process
Problem solving processProblem solving process
Problem solving process
Satveer Mann
 
Character set in C
Character set in CCharacter set in C
Character set in C
Satveer Mann
 
Introduction to c
 Introduction to c Introduction to c
Introduction to c
Satveer Mann
 

More from Satveer Mann (8)

Data types in C
Data types in CData types in C
Data types in C
 
keywords and identifiers
 keywords and identifiers keywords and identifiers
keywords and identifiers
 
Preprocessor directives
Preprocessor directivesPreprocessor directives
Preprocessor directives
 
Program structure of c
Program structure of cProgram structure of c
Program structure of c
 
Algorithms, flow charts and pseudocodes
Algorithms, flow charts and pseudocodesAlgorithms, flow charts and pseudocodes
Algorithms, flow charts and pseudocodes
 
Problem solving process
Problem solving processProblem solving process
Problem solving process
 
Character set in C
Character set in CCharacter set in C
Character set in C
 
Introduction to c
 Introduction to c Introduction to c
Introduction to c
 

Recently uploaded

Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Leena Ghag-Sakpal
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
S. Raj Kumar
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 

Recently uploaded (20)

Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
Bed Making ( Introduction, Purpose, Types, Articles, Scientific principles, N...
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 

Constants in C

  • 2. Constant Refer to fixed values. Values do not change during the execution of a program. Uses the secondary storage area. For every language, constants are same. By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 2
  • 3. Types of Constant Constant Numeric constant Integer constant Real constant Character constant Single character constant String constant By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 3
  • 4. Numeric constant By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 4 Have numeric value having a combination of sequence of digits. 0-9 as alone digits or combination of 0-9 with or without decimal point.
  • 5. Integer numeric constant Decimal integer Octal integer Hexadecimal integer By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 5
  • 6. Integer numeric constant Decimal integer •A set of digits 0-9, preceded by an optional – or + sign. •Embedded spaces, commas, non-digit characters are not permitted between digits. •Examples are 123, -321, 0 , 654321, +78 Octal integer •Consist of any combination of digits 0-7, with a leading 0. •Examples are 037, 0, 0435, 0551 Hexadecimal Integer •Sequence of digits preceded by 0x or 0X. •Also include alphabets A through F or a through f representing numbers 10-15. •Examples are 0x2, 0X9F, oxbcd, 0X. By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 6
  • 7. Range of integer constants Generally it is machine dependent for largest integer value. On 16-bit machines, it is 32767. On 32-bit machines, it is 2,147,483,647. Also possible to store larger integer constants by appending qualifiers like U, L and UL. By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 7
  • 8. Examples: Unsigned integer Unsigned long integer Long integer • 56789U • 56789u • 985674213UL • 985674213ul • 9876543L • 9876543l By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 8
  • 9. Real Constant Real constants Are represented by numbers containing fractional parts like 15.456 Are shown in decimal notation, having a whole number followed by a decimal point and the fractional point. Possible to omit digits before or after the decimal points e.g. 215. , .95 , -.72 , +.5 May also be expressed in exponential(or scientific) notation. General form is mantissa e exponent Example is 215.65 may be written as 2.1565e2 e2 means multiply by 102 By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 9
  • 10. Real Constants Real constants Mantissa is either a real number represented in decimal notation or an integer. Exponent is an integer number with an optional plus or minus sign. Letter e separating the mantissa and the exponent can be written inn uppercase or lowercase. Embedded white space is not allowed. Are useful for very large or very small numbers e.g. 9500000000 may be written as 9.5E9 or 95E8 and -0.000000348 be as -3.48E-7 By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 10
  • 11. Single character constant Contains a single character enclosed in single quote marks e.g. ‘5’ , ‘X’. Character constant is not the same as the numbers. Have integer values known as ASCII values e.g. ‘a’ have 97 as its ASCII value.. Also possible to perform arithmetic operations on character constants. By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 11
  • 12. String constants A sequence of characters enclosed in double quotes. Characters may be letters, numbers, special characters, and blank spaces e.g. “Hello”, “1987” Single character string is not equivalent to a character constant and does not have an equivalent integer value. By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 12
  • 13. THANK YOU By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 13