0% found this document useful (0 votes)
28 views2 pages

Programming - Constants and Variables

Constants and variables are used in C programming. There are several types of constants in C including integer, real, single character, and string constants. Integer constants can be decimal, octal, or hexadecimal and consist of digits with optional signs. Real constants represent quantities with fractional parts in decimal notation or exponential form. Variables are used to store and manipulate data during program execution and can be modified unlike constants.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Programming - Constants and Variables

Constants and variables are used in C programming. There are several types of constants in C including integer, real, single character, and string constants. Integer constants can be decimal, octal, or hexadecimal and consist of digits with optional signs. Real constants represent quantities with fractional parts in decimal notation or exponential form. Variables are used to store and manipulate data during program execution and can be modified unlike constants.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming - Constants and Variables

Category: C Language
Comments (21)

Table of Contents
C Programming - Constants and Variables
C Programming - Constants and Variables - Page 2
C Programming - Constants and Variables - Page 3
C Programming - Constants and Variables - Page 2
Page 2 of 3

Constants
A constant value is the one which does not change during the execution of a program. C
supports several types of constants.

1. Integer Constants
2. Real Constants
3. Single Character Constants
4. String Constants

Integer Constants
An integer constant is a sequence of digits. There are 3 types of integers namely decimal
integer, octal integers and hexadecimal integer.

Decimal Integers consists of a set of digits 0 to 9 preceded by an optional + or - sign.


Spaces, commas and non digit characters are not permitted between digits. Example for
valid decimal integer constants are

123
-31
0
562321
+ 78

Some examples for invalid integer constants are

15 750
20,000
Rs. 1000

Octal Integers constant consists of any combination of digits from 0 through 7 with a O at
the beginning. Some examples of octal integers are

O26
O
O347
O676
Hexadecimal integer constant is preceded by OX or Ox, they may contain alphabets from
A to F or a to f. The alphabets A to F refers to 10 to 15 in decimal digits. Example of valid
hexadecimal integers are

OX2
OX8C
OXbcd
Ox

Sponsored Links

Real Constants
Real Constants consists of a fractional part in their representation. Integer constants are
inadequate to represent quantities that vary continuously. These quantities are represented
by numbers containing fractional parts like 26.082. Example of real constants are

0.0026
-0.97
435.29
+487.0

Real Numbers can also be represented by exponential notation. The general form for
exponential notation is mantissa exponent. The mantissa is either a real number expressed
in decimal notation or an integer. The exponent is an integer number with an optional plus
or minus sign.

You might also like