Home Show/Hide Menu
C Tutorials
➜ C Language
  - Features of C
  - First C Program
  - Compilation in C
  - C Character Set
  - Tokens
  - Keywords
  - Identifiers
  - Constants
  - Operators
  - Data Types
  - Variables
  - Type Casting
  - Comments
  - Input/Output
  - Escape Sequence
  - Programming Errors
➜ Control Statements
  - if Statement
  - if-else Statement
  - Nested if-else
  - else-if
  - switch Statement
  - Loop
  - while loop
  - do while loop
  - for loop
  - break
  - continue & goto
  - Nested Loop
  - Infinite Loop
➜ Functions
  - What is function
  - Call by Value & Reference
  - Recursive function
  - Storage Classes
➜ Array
  - 1-D Array
  - 2-D Array
  - Return an Array
  - Array to Function
➜ C Pointers
  - Pointers
  - Pointer to Pointer
  - Pointer Arithmetic
  - Dangling Pointers
  - sizeof() operator
  - const Pointer
  - void pointer
  - Dereference Pointer
  - Null Pointer
  - Function Pointer
  - Function pointer as argument
➜ Memory Management
  - Memory Layout of C
  - Dynamic memory
  - calloc()
  - malloc()
  - realloc()
  - free()
➜ Strings
  - gets() & puts()
  - String Functions
  - strlen()
  - strcpy()
  - strcat()
  - strcmp()
  - strrev()
  - strlwr()
  - strupr()
  - strstr()
➜ C Math
  - Math Functions
➜ Enum, Structure & Union
  - Enum
  - Structure
  - typedef
  - Array of Structures
  - Nested Structure
  - Structure Padding
  - Union
➜ File Handling
  - fprintf() fscanf()
  - fputc() fgetc()
  - fputs() fgets()
  - fseek()
  - EOF and feof()
  - fsetpos()
  - tmpfile()
  - rewind()
  - ftell()
  - lseek()
➜ Preprocessor
  - Preprocessor
  - Macros
  - #include
  - #define
  - #undef
  - #ifdef
  - #ifndef
  - #if
  - #else
  - #error
  - #pragma
➜ Command Line
  - Arguments

Constants in C Language

Constants are like regular variable, except that their value can not be modified during the entire execution of the program once they are defined.


Constants Types

Constants are categorized into two basic types : 1) Primary Constants, & 2) Secondary Constants. Each types has its subtypes/categories, which are shown below :

  • Primary Constants
    • Integer Constant
      • Decimal Integer - Example: 12, -597, 0, 56789
      • Octal Integer - Example: 045, 0213 → starts with 0
      • Hexadecimal Integer - Example: 0x2b, 0x6d, 0xab → starts with 0x
    • Real or Floating Points Constant - Example: 75.25, 3.27359, 427359E-5L → e or E represents signed exponent
    • Character Constant
      • Single Character Constants - Example: 'A', 'b', 'W', 'x', '5', ';'
      • String Constants - Example: "Hi!", "Hello World", 2021", "5+4"
      • Backslash Character Constants - Example: \t for tab, \n for new line
  • Secondary Constants
    • Array
    • Pointer
    • Structure
    • Union
    • Enum

Backslash Character Constants

Given below is the list of special characters and their usages.

 Backslash character  Meaning
\a  Alert or Beep sound
\b  Backspace
\f  Form feed
\n  New line
\r  Carriage return
\t  Horizontal tab
\v  Vertical tab
\"  Double quote
\'  Single quote
\\  Backslash
\?  Question mark
\N  Octal constant
\XN  Hexadecimal constant
\0  Null


ADVERTISEMENT