top of page
PREVIOUS STEP
NEXT STEP
NEXT STEP
PREVIOUS STEP
MY BUTTON

C LANGUAGE

Constants

    Constants are the terms that can't be changed during the execution of a program. For example:

1, 2.5, "Programming is easy." etc.

 

In C, constants can be classified as:

 

  • Integer constants

     Integer constants are the numeric constants

(constant associated with number) without any fractional part or exponential part. There are three types of integer constants in C language:

decimal constant(base 10), octal constant(base 8) and hexadecimal constant(base 16) .

Decimal digits: 0 1 2 3 4 5 6 7 8 9

Octal digits: 0 1 2 3 4 5 6 7

Hexadecimal digits: 0 1 2 3 4 5 6 7 8 9 A B C D E F.

For example:Decimal constants: 0, -9, 22 etc

Octal constants: 021, 077, 033 etc

Hexadecimal constants: 0x7f, 0x2a, 0x521 etc

 

     Notes:You can use small caps a, b, c, d, e, f instead of uppercase letters while writing a hexadecimal constant.Every octal constant starts with 0 and hexadecimal constant starts with 0x in C programming.

 

  • Floating-point constants

     Floating point constants are the numeric constants that has either fractional form or exponent form. For example:-

2.0 0.0000234 -0.22E-5

 

Note:Here, E-5 represents 10-5.

Thus, -0.22E-5 = -0.0000022.

 

Character constants

     Character constants are the constant which use single quotation around characters.

For example:

'a', 'l', 'm', 'F' etc

 

Escape Sequences

     Sometimes, it is necessary to use newline(enter), tab, quotation mark etc. in the program which either cannot be typed or has special meaning in C programming. In such cases, escape sequence are used.

 

For example:

\n is used for newline.

The backslash( \ ) causes "escape" from the normal way the characters are interpreted by the compiler.

 

Escape Sequences CharacterS

  • \bBackspace

  • \fForm feed

  • \nNewline

  • \rReturn

  • \tHorizontal tab

  • \vVertical tab

  • \\Backslash

  • \'Single quotation mark

  • \"Double quotation mark

  • \?Question mark

  • \0Null character

 

String constants

     String constants are the constants which are enclosed in a pair of double-quote marks.

For example:

"good" //string constant "

" //null string constant "

" //string constant of six white space "x" //string constant having single character. "Earth is round\n"

//prints string with newline

 

Enumeration constants

     Keyword enum is used to declare enumeration types. For example:enum color {yellow, green, black, white};Here, the variable name is color and yellow, green, black and white are the enumeration constants having value 0, 1, 2 and 3 respectively by default.

    For more information about enumeration, visit page: Enumeration Types.

MY BUTTON
DOWNLOADS
EXAMPLES
SEE ALSO
REPORT AN ERROR
UNION
PREPROCESSOR
STRUCTURE
FUNCTION
ARRAY
STORAGE CLASS
TYPE QUALIFIER
CASE CONTROL
LOOP
DECISION
OPERATORS
VARIABLE
CONSTANT
KEYWORDS
DATA TYPE
PRINTF &SCANF
BASIC

© 2014 by KAILASH LALE.

FAVORITES

FOLLOW US ON

CONTACT ME

Tel: +91 8446823181
Skype: deathreveals
Mail: shareandlearnhub@gmail.com

bottom of page