Saturday, 31 March 2018

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 constant
 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 integers.
  1. 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 constant are
15 750
20,000
Rs. 1000


2. Octal Integer 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

3. Hexadecimal Integer constants 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

Real Constants
   Real constants consists of a fractional part in their representation.Integer constant 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.

Single Character Constants
  A single Character constant represent a single character which is enclosed in a pair of quotation symbols.
Example for character constant are
'5'
'x'

String Constants
   A string constants is a set of character enclosed in double quotation marks. The character in a string constant sequence may be a alphabet, number, special character and blank space. Example of string constants are-
"IRAWEN"
"1234"
"God Bless"
"!....?"

Backslash Character Constant [Escape Sequence]
 Backslash character constants are special character used in output functions. Although they contain two characters they represent only one character.
For example "\n" is the new line character constant. and
    "\t" is to give a tab space for formatting.

0 Comments:

Post a Comment

Popular Posts

Categories

100 Python Programs for Beginner (53) AI (34) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (173) C (77) C# (12) C++ (82) Course (67) Coursera (226) Cybersecurity (24) data management (11) Data Science (128) Data Strucures (8) Deep Learning (20) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (34) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (59) Meta (22) MICHIGAN (5) microsoft (4) Nvidia (3) Pandas (4) PHP (20) Projects (29) Python (932) Python Coding Challenge (358) Python Quiz (23) Python Tips (2) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (3) Software (17) SQL (42) UX Research (1) web application (8) Web development (2) web scraping (2)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses