SlideShare ist ein Scribd-Unternehmen logo
1 von 7
CONSTANTS

       IN C
TYPES OF C CONSTANTS
                                C Constants

    Primary Constants                           Secondary Constants

    Integer Constants                             Array, Pointer ,
      Real Constants                             Structure , Union
   Character Constants                              Enum etc.
     String constants
     Escape sequence



*CONSTANT is a Quantity that doesn’t change……
INTEGER CONSTANTS


    - sequence of digits
   Three types
   Decimal: set of digits,0 through 9
   123, -87, 0, +56 <- valid $1000, 15 750, (20,000) <-Invalid
   Octal: combination of 0 to 7 with leading zero. i.e. 075,
    051 are octal
   Hexadecimal: sequence of digits 0-9,A..F/a..f …..
    Preceded by 0x or 0X
   like 0x2, 0x3A, 0Xe5,etc are hexadecimal numbers.
REAL CONSTANTS(FLOATING POINT)

   - to represent varying entity like prices. it contain
    fractional parts.
   in decimal notation 34.32, -0.56, .4555 , 0.00054 etc.
   In exponential notation(or scientific) 215.65 may be
    written as 2.1565e2 also valid
   More 0.65e4 ,12e-2, 3.18E3.
   -> Should the following be valid ?
      1.5E2.5 (YES / NO ) ?
SINGLE CHARACTER CONSTANTS


    -a single character enclosed within a pair of single
    quote marks I.e ‘y’ , ‘4’, ‘;’ , ‘ ‘, etc.
    - character constants have integer values known as
    ASCII (American Standard Code for Information
    Interchange) values.
   i.e. printf(“%d”,’a’); will print no. 97, the ascii value of
    the letter a.
   While printf(“%c”,97); will print --- a
   *error in book statement instead of ’97’ it should be
    only 97
STRING CONSTANTS



    -sequence of characters enclosed in double quotes
    like
   “hello!” , “hi 18”, “well done”, “a”
   Remember that “x” and ‘x’ is different because ‘x’ has
    equivalent integer value in ASCII.
   String constants are normally used like displaying
    menu/messages.
BACKSLASH CHARACTER CONSTANTS




   - used in output functions…
   - ‘n’ stands for new line character
   - ‘b’ for back space
   - ‘t’ for making horizontal tab
   all above represents one character, although they
    consist of two chars.
   These char combination are known as “escape
    sequences”

Weitere ähnliche Inhalte

Andere mochten auch

09 binary-trees
09 binary-trees09 binary-trees
09 binary-trees
Tech_MX
 
14.jun.2012
14.jun.201214.jun.2012
14.jun.2012
Tech_MX
 
Trends and technologies in system softwares
Trends and technologies in system softwaresTrends and technologies in system softwares
Trends and technologies in system softwares
Tech_MX
 
Graph theory
Graph theoryGraph theory
Graph theory
Tech_MX
 
Mutable and immutable classes
Mutable and  immutable classesMutable and  immutable classes
Mutable and immutable classes
Tech_MX
 
More on Lex
More on LexMore on Lex
More on Lex
Tech_MX
 
What are interpersonal skills
What are interpersonal skillsWhat are interpersonal skills
What are interpersonal skills
Tech_MX
 
Linear programming problem
Linear programming problemLinear programming problem
Linear programming problem
Tech_MX
 
Investment problem
Investment problemInvestment problem
Investment problem
Tech_MX
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2
Tech_MX
 
Buddy system final
Buddy system finalBuddy system final
Buddy system final
Tech_MX
 
Set data structure
Set data structure Set data structure
Set data structure
Tech_MX
 
Graph data structure
Graph data structureGraph data structure
Graph data structure
Tech_MX
 
Inline function
Inline functionInline function
Inline function
Tech_MX
 
E post office system
E post office systemE post office system
E post office system
Tech_MX
 
Combined paging and segmentation
Combined paging and segmentationCombined paging and segmentation
Combined paging and segmentation
Tech_MX
 

Andere mochten auch (19)

09 binary-trees
09 binary-trees09 binary-trees
09 binary-trees
 
14.jun.2012
14.jun.201214.jun.2012
14.jun.2012
 
Trends and technologies in system softwares
Trends and technologies in system softwaresTrends and technologies in system softwares
Trends and technologies in system softwares
 
Graph theory
Graph theoryGraph theory
Graph theory
 
Mutable and immutable classes
Mutable and  immutable classesMutable and  immutable classes
Mutable and immutable classes
 
More on Lex
More on LexMore on Lex
More on Lex
 
What are interpersonal skills
What are interpersonal skillsWhat are interpersonal skills
What are interpersonal skills
 
Linear programming problem
Linear programming problemLinear programming problem
Linear programming problem
 
Investment problem
Investment problemInvestment problem
Investment problem
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2
 
Buddy system final
Buddy system finalBuddy system final
Buddy system final
 
Set data structure
Set data structure Set data structure
Set data structure
 
Graph data structure
Graph data structureGraph data structure
Graph data structure
 
Inline function
Inline functionInline function
Inline function
 
E post office system
E post office systemE post office system
E post office system
 
Combined paging and segmentation
Combined paging and segmentationCombined paging and segmentation
Combined paging and segmentation
 
Linkers
LinkersLinkers
Linkers
 
Uid
UidUid
Uid
 
Spss
SpssSpss
Spss
 

Ähnlich wie Constants

Chapter 13.1.1
Chapter 13.1.1Chapter 13.1.1
Chapter 13.1.1
patcha535
 

Ähnlich wie Constants (20)

Chapter 13.1.1
Chapter 13.1.1Chapter 13.1.1
Chapter 13.1.1
 
Cse115 lecture14strings part01
Cse115 lecture14strings part01Cse115 lecture14strings part01
Cse115 lecture14strings part01
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
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
 
C language (more)
C language (more)C language (more)
C language (more)
 
Java Object Orientend Programming 1.pptx
Java Object Orientend Programming 1.pptxJava Object Orientend Programming 1.pptx
Java Object Orientend Programming 1.pptx
 
Unit 2. Elements of C
Unit 2. Elements of CUnit 2. Elements of C
Unit 2. Elements of C
 
C/C++ language Presentation
C/C++ language PresentationC/C++ language Presentation
C/C++ language Presentation
 
Fundamentals of C Programming Language
Fundamentals of C Programming LanguageFundamentals of C Programming Language
Fundamentals of C Programming Language
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
Regular expressions in oracle
Regular expressions in oracleRegular expressions in oracle
Regular expressions in oracle
 
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdfSTRINGS IN C MRS.SOWMYA JYOTHI.pdf
STRINGS IN C MRS.SOWMYA JYOTHI.pdf
 
Introduction to C Programming - R.D.Sivakumar
Introduction to C Programming -  R.D.SivakumarIntroduction to C Programming -  R.D.Sivakumar
Introduction to C Programming - R.D.Sivakumar
 
PROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptxPROGRAMMING IN C - Inroduction.pptx
PROGRAMMING IN C - Inroduction.pptx
 
C tokens.pptx
C tokens.pptxC tokens.pptx
C tokens.pptx
 
Constants
ConstantsConstants
Constants
 
2 1 data
2 1  data2 1  data
2 1 data
 
Introduction
IntroductionIntroduction
Introduction
 
Array &strings
Array &stringsArray &strings
Array &strings
 
Strings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiStrings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothi
 

Mehr von Tech_MX

Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
Tech_MX
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 
String & its application
String & its applicationString & its application
String & its application
Tech_MX
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2
Tech_MX
 
Stack data structure
Stack data structureStack data structure
Stack data structure
Tech_MX
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
Tech_MX
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
Tech_MX
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
Tech_MX
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
Tech_MX
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pc
Tech_MX
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbms
Tech_MX
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)
Tech_MX
 
Memory dbms
Memory dbmsMemory dbms
Memory dbms
Tech_MX
 
Linear regression
Linear regressionLinear regression
Linear regression
Tech_MX
 
Keyboard interrupt
Keyboard interruptKeyboard interrupt
Keyboard interrupt
Tech_MX
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loaders
Tech_MX
 
Interpersonal communication
Interpersonal communicationInterpersonal communication
Interpersonal communication
Tech_MX
 
Interesting applications of graph theory
Interesting applications of graph theoryInteresting applications of graph theory
Interesting applications of graph theory
Tech_MX
 

Mehr von Tech_MX (20)

Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
String & its application
String & its applicationString & its application
String & its application
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 
Parsing
ParsingParsing
Parsing
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pc
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbms
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)
 
Memory dbms
Memory dbmsMemory dbms
Memory dbms
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Keyboard interrupt
Keyboard interruptKeyboard interrupt
Keyboard interrupt
 
Introduction to loaders
Introduction to loadersIntroduction to loaders
Introduction to loaders
 
Interpersonal communication
Interpersonal communicationInterpersonal communication
Interpersonal communication
 
Interesting applications of graph theory
Interesting applications of graph theoryInteresting applications of graph theory
Interesting applications of graph theory
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

Constants

  • 1. CONSTANTS IN C
  • 2. TYPES OF C CONSTANTS C Constants Primary Constants Secondary Constants Integer Constants Array, Pointer , Real Constants Structure , Union Character Constants Enum etc. String constants Escape sequence *CONSTANT is a Quantity that doesn’t change……
  • 3. INTEGER CONSTANTS  - sequence of digits  Three types  Decimal: set of digits,0 through 9  123, -87, 0, +56 <- valid $1000, 15 750, (20,000) <-Invalid  Octal: combination of 0 to 7 with leading zero. i.e. 075, 051 are octal  Hexadecimal: sequence of digits 0-9,A..F/a..f ….. Preceded by 0x or 0X  like 0x2, 0x3A, 0Xe5,etc are hexadecimal numbers.
  • 4. REAL CONSTANTS(FLOATING POINT)  - to represent varying entity like prices. it contain fractional parts.  in decimal notation 34.32, -0.56, .4555 , 0.00054 etc.  In exponential notation(or scientific) 215.65 may be written as 2.1565e2 also valid  More 0.65e4 ,12e-2, 3.18E3.  -> Should the following be valid ?  1.5E2.5 (YES / NO ) ?
  • 5. SINGLE CHARACTER CONSTANTS  -a single character enclosed within a pair of single quote marks I.e ‘y’ , ‘4’, ‘;’ , ‘ ‘, etc.  - character constants have integer values known as ASCII (American Standard Code for Information Interchange) values.  i.e. printf(“%d”,’a’); will print no. 97, the ascii value of the letter a.  While printf(“%c”,97); will print --- a  *error in book statement instead of ’97’ it should be only 97
  • 6. STRING CONSTANTS  -sequence of characters enclosed in double quotes like  “hello!” , “hi 18”, “well done”, “a”  Remember that “x” and ‘x’ is different because ‘x’ has equivalent integer value in ASCII.  String constants are normally used like displaying menu/messages.
  • 7. BACKSLASH CHARACTER CONSTANTS  - used in output functions…  - ‘n’ stands for new line character  - ‘b’ for back space  - ‘t’ for making horizontal tab  all above represents one character, although they consist of two chars.  These char combination are known as “escape sequences”