C Foundation

What is C? C Compiler Installation C Extensions C Compiler C Interpreter C Program Structure

C Basics

C Keywords C Data Types C Identifiers C Variables C Constant C Escape Sequences C Constant and Volatile C Typecast


What is Operator C Comma Operator C Arithmetic Operators C Relational Operators C Logical Operators C Bitwise Operators C Conditional Operators C : : Operator C Operator Priority

Basic IO's

Basic IO's C Formatted Functions C Unformatted Functions C Common Functions

Control Statements

What is Control Statement C if Statement C if else Statement C Nested if Statement C Else if Statement C Break Statement C Continue Statement C Switch Statement C Goto Statement


What is Control Loop C for Loop C Nested for Loop C while Loop C Nested while Loop C do while Loop C Nested do while loop


What is Function C User Defined Functions C Recursion C Passing Parameters


Scope C Local Scope C Global Scope

Storage Classes

What is Storage Class C Auto C Extern C Static C Register


What is Array C One Dimensional Array C Two Dimensional Array C Multi Dimensional Array C Arrays Of Strings


What is String C String Functions


What is Pointer C Pointers Arithmetic C Pointer to Pointer C Pointers and Arrays C Pointers and Strings C Pointer to Functions Void Pointers Null Pointers C Null and Void Pointer


What is Structure C Struct within Struct C Array within Structure C Pointer to Structure C Structure and Function C Enum C Bitfield Structure C Type def


What is Union


What is File C read a file C write a file C File Handling C Error Handling C Low Level Disk I/O C Other file functions

Memory Allocation

What is Memory Allocation C Malloc() C Calloc() C Free() C Realloc() C Coreleft()

C Reference

All ASCII Code Basic C Questions

C Interview

C Interview Sets All Star Patterns All Number Patterns All Alphabet Patterns All Series Patterns
The ones who are crazy enough to think they can change the world are the ones who do.
- Steve Jobs

C Constants

What is Constant Variable?

Constant variable, does not change its value during the execution of a program. A constant is a data value written by a programmer. Constants may be belonging to any of the data type(int, float, char). There are 4 basic types of constants. They are

  • Integer Constant.
  • Floating Point Constant.
  • Character Constant.
  • String Constant.

Constants Types

Types of Constant in C

Integer Constants

  • An integer constants consists of sequence of Integer numbers from 0 to 9.
  • Decimal points, black spaces, commas cannot be included within an integer constants.
  • An Integer constants can either be positive or negative or zero.
  • The number without sign can be assumed as positive
  • Integer constants can be classified into  3  ways . They are
    • Decimal Integer Constants.
    • Octal Integer Constants.
    • Hexadecimal Integer Constants.

Decimal Integer Constants

A Decimal integer constants consist of any combination of digits from 0 to 9. A Decimal integer constants can contain two or more digits, but first digit should not be 0. Base value of decimal integer is 10.

Valid Decimal integer Constants in C Programming

0 12 856 456844

Invalid Decimal Integer Constants

45,565 invalid character (,)
25.0 invalid character(.)
1 2 3 invalid character(blank space)
12-23-34-456 invalid character(-)
051 first digit cannot be a zero

Octal Integer Constants

An Octal integer should starts with 0 in order to identify the constant as an octal integer number. An Octal integer constants consist of any combination of numbers between 0 to 7. Base value of Octal integer constants is 8.

Valid Octal Integer Constants in C Programming

0 012 0856 0456844

Invalid Octal Integer Constants

4725 does not starts with 0
01491 invalid digit(9)
012.23 invalid character(.)
051-43 invalid character(-)

Hexadecimal Integer Constants

A Hexadecimal integer constants can be a combination of any numbers in the range of 0 to 9 and a to f or A to F. Here A to F denotes 0 to 15. A Hexadecimal integer constants should starts with either 0x or 0X. Base value of Hexadecimal integer constants is 16.

Valid Hexa Integer in C Programming

0x 0X12 0x8A6 0x4a84b4

Invalid Hexa Integer Constants in C Programming

4725 does not starts with 0x
0x1H9 invalid charcter(H)
0X12.23 invalid character (.)
0X51-43 invalid character(-)

Unsigned or Long Integer Constants

Unsigned or Long Integer Constants may exceed the range of Integer. Unsigned or Long Integer Constants are identified by the suffix u or l. Here

  • u represents unsigned int.
  • L represents long int.

Example of unsigned and long integer constants

4541U unsigned int
4558L long int

Floating point constant

A floating point constant consist of integer part, decimal point and fractional part. A floating point constant contains exponential field e or E followed by an integer. A normal decimal point value will be treated as double until a suffix f is added to the decimal point value. Decimal point value using double will be more accurate than float. Adding suffix l or L to the Decimal point value will be treated as long double. A floating point constant with an exponent is essentially the same as scientific notation, except that base 10 is replaced by e or E. Exponential notation is useful in representing the numbers whose magnitudes are very large or very small.

Valid and Invalid Floating Point Constants

Valid Floating Point Constants Invalid Floating Point Constants
47.00 47
0.4 0 5

What is Mantissa and Exponent?

Consider the number 257.47. This can also be return as 0.25747E3. The sequence of digits after decimal point (25747) is a mantissa. The power of E (3) is known as exponent.

Valid and Invalid Exponential notation

Valid Exponential notation Invalid Exponential notation
542.254E6 7.5.3E4
542.254e6 7.5.3e    4

Character Constants in C Programming

A character constant is a single character enclosed within single quotes ' '. A character constant also represented with a single digit or a single special character or white space enclosed within a single quotes. All PC make use of ASCII(American Standard Code for Information Interchange) character set, where each integer character is numerically encoded. A character constant occupies a single byte.

Valid and Invalid Character Constants

Valid Character Constants Invalid Character Constants
'a' 'ab'
'1' '22'

String Constants

A string constant is a sequence of characters enclosed within double quotes " ". The Characters may consists of letters, digits, escape sequences and spaces. A string constant always ends with null (/0). A string constant occupies a two bytes.

Valid and Invalid String Constants

Valid String Constants Invalid String Constants
'Hello Programmer' 'Hello Programmer"
"Hello Programmer" "Hello Programmer'

Report Us

We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.


We to update you