C Constants C

  • Integer constants.
  • Floating point constants.
  • Character constants.

A constant can be defined as a quantity that does not change. There are 3 different types of constants. Integer, floating point and character constants.

Integer Constants
Integer constant is an integer quantity containing sequence of digits. It has no decimal point. It can be either positive or negative. Blanks and commas are not allowed within integer constants. The value ofthe constant must lie within the range of integer values. A decimal integer constant can consist of any combination of digits taken from 0 through 9.

E.g. 0 5280 9999

An octal integer constant can consist of any combination of digits from 0 through 7. The first digit must be 0.

E.g. 0 01 0743

A hexadecimal integer constant must begin with 0x or 0x, followed by any combination of digit from 0 through 9 and a through f.

E.g. 0x1 oxab7f

Certain suffixes can be given to constants, which identify them for the type

Integer Constants

5000U unsigned (decimal)
0x5000U unsigned (hex)
1234UL unsigned long (decimal)
0777U unsigned (octal)

Floating Point Constants
Floating point constant contains a decimal point or an exponent. It could be either negative or positive. No commas or blanks are allowed within a real constant
E.g. +3.2e-5, -0.2e-5, -32.76

Floating Point Constants

Character Constants
A character constant is a character enclosed in single quotation marks. A character constant can contain only one character.
E.g. ‘A’ ‘3’ ‘$’
Each character has a corresponding ASCII value (which is the numeric value of character in machine’s character set.) as given below.

Character Constants

Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

C Topics