Friday 8 March 2013

Constants



Constants: A constant is a value that does not change during the program execution. As its name implies it is a constant or fixed value. Constants are declared with the ‘const’ keyword. Constants in every language remain same. In some languages, constants are also known as literals. The constants can be classified as integer constant, floating constant, character constant and string constant. For example: const data_type var; 

Integer Constant: An integer is a whole number without decimal point. An integer may be either 0-9 digits or the combination of 0-9. Integer can be further divided into three different number systems: decimal (base 10), octal (base 8) and hexadecimal (base 16).
Octal: 1) It consists of numeric range 0-7 or combination of 0-7 numbers.
2) The first digit must be 0 in order to identify the constant as an octal.
3) For example: 00, 010, and 0200.
Decimal: 1) It consists of any combination of 0-9 digits. It is the most commonly used number system.
2) It is normal counting number of mathematics. The first digit needs not to be zero.
3) For example: 0, 8, 156, 25378 etc.
Hexadecimal: It consists of 0-9 digits and alphabets ‘a’ to ‘f’ or ‘A’ to ‘F’. Here ‘a’ to ‘f’ represents the decimal values 10 to 15. ‘A’ or ‘a’ is 10, ‘B’ or ‘b’ is 11 and so on.
2) A hexadecimal number must begin with 0x or OX.
3) For example: 0x0, 0x10, 0x265 etc.
Rules for integer constants: 1) it may be either positive or negative.
2) It must not have any decimal point.
3) No commas or blank spaces are allowed in an integer.
4) It must have at least one digit.


Floating Constant: A floating point constant has a real value. It is a numeric value with decimal point. It may be either of single precision or of double precision type. It may be written in two forms called the fraction form and exponent form.
Fraction form: In the fraction form, the value is represented as a whole number followed by a decimal point. For example: 130.35, -0.67
Rules for fraction form: 1) a decimal point should be present.
2) No commas or spaces are allowed.
3) It may be +ve or -ve but default is +ve.
Exponential form: In the exponential form a floating point constant has a mantissa part and exponent. The mantissa part and exponent part should be separated by e or E. For example: a number 234.56 can be written as 2.3456e2 or 2.3456e+2 i.e. 2.3456*10^2 Here 2.3456 represents mantissa part and the part after 'e' is exponent part, which has a base 10.
Rules: 1) the mantissa part can be written in positive or negative.
2) Spaces and commas are not allowed.
3) Letter e can be written in uppercase or lowercase.


Character constant: A character constant is a single alphabet, single digit or single symbol which is enclosed in single quotes (' '). Every character constant has a unique ASCII value. For example ASCII value of 'A' is 65. The maximum length of a character constant is only one character. For example: 'a', '&', '2' etc.
A character can be any ASCII character, printable or not printable from values -128 to 127. (But only 0 to 127 are used.) Control characters i.e. non printable characters are put into programs by using a backslash \ and a special character or number. The characters and their meanings are:
\b
backspace BS 
\f
form feed FF (also clear screen) 
\n
new line NL (like pressing return) 
\r
carriage return CR (cursor to start of line) 
\t
horizontal tab HT 
\v
vertical tab (not all versions) 
\"
double quotes (not all versions) 
\'
single quote character ' 
\\
backslash character \ 

These are some certain character constants that start with backslash (\). Such characters are known as escape sequence character. There are predefined in compile and used with output statements. These characters are non printable and have some specific tasks.
String constant: A string constant is a group of characters, which is enclosed in double quotes. So it is also called double quotes character constant. The characters enclosed in double quotes may be alphabet, digits, special symbols, escape sequence and spaces. For example: "This is my pen", "hi...\ this is Vijraj Bhargav", "My mobile number is 9872871471".

9 Comments:

At 16 November 2017 at 02:36 , Blogger I Digital Academy said...

Its a nice post.
Best Web Designing Training in Bangalore
Best Oracle Training in Bangalore

 
At 19 October 2018 at 20:07 , Blogger Unknown said...

Thanks very interesting blog!
Cara Melindungi Mata Dari Paparan Radiasi Hp dan Komputer
Cara Menghilangkan Luka Menebal Di Kulit
CaraMenghilangkan Benjolan Di Bawah Ketiak

 
At 21 October 2018 at 17:55 , Blogger Unknown said...

Thanks informas Cara Mengatasi Miss V Bau Amis
Cara Mengobati Gatal Menahun Yang Tak Kunjung Sembuh inya ..

 
At 27 October 2018 at 01:02 , Blogger Unknown said...

Thanks for giving excellent informations. Your web-site is very cool.
Cara Menghilangkan Kolesterol Di Mata
Cara Mengatasi Infeksi Keputihan
Cara Mengatasi Infark Miokard Akut
Cara Mengatasi Gangguan Makan pada Anak
Pengobatan Retina Mata Putus Selain Operasi

 
At 5 February 2019 at 02:42 , Blogger sathya shri said...

Hello I am so delighted I found your blog, I really found you by mistake, while I was looking on Yahoo for something else, anyways I am here now and would just like to say thanks for a tremendous post. Please do keep up the great work.

DevOps Training in Bangalore

DevOps Training in Bangalore

DevOps Training in Bangalore

DevOps Training in Marathahalli

DevOps Training in Pune

DevOps Online Training-gangboard

 
At 15 April 2019 at 03:57 , Blogger QuickBooks Help Number said...

QuickBooks has played a very important role in redefining the way you look at things now. By introducing so many versions namely Pro, Premier, Enterprise, Accountant, Payroll, POS etc. QuickBooks Payroll is one of the most desired software when it comes to dealing with one’s finances and managing it. This software has equipped almost all the QuickBooks users with so much of strength that they feel accomplished. QuickBooks Payroll is one such software that has instilled the correct sense of using your money and its management in the best possible manner.

QuickBooks Payroll Support | QuickBooks Support | QuickBooks POS Support

 
At 27 April 2019 at 02:42 , Blogger prestige elysian said...

Information provided by you is very helpful and informative. Keep On updating such information.

prestige elysian


 
At 18 November 2019 at 21:26 , Blogger Realtime Experts said...

It’s great blog to come across a every once in a while that isn’t the same out of date rehashed material. Fantastic read.Oracle Applications Training in Bangalore

 
At 25 April 2021 at 08:03 , Blogger Plumbing & HVAC Services San Diego said...

Compre documentos en línea, documentos originales y registrados.
Acerca de Permisodeespana, algunos dicen que somos los solucionadores de problemas, mientras que otros se refieren a nosotros como vendedores de soluciones. Contamos con cientos de clientes satisfechos a nivel mundial. Hacemos documentos falsos autorizados y aprobados como Permiso de Residencia Español, DNI, Pasaporte Español y Licencia de Conducir Española. Somos los fabricantes y proveedores de primer nivel de estos documentos, reconocidos a nivel mundial.

Comprar permiso de residencia,
permiso de residenciareal y falso en línea,
Compre licencia de conducir en línea,
Compre una licencia de conducir española falsa en línea,
Comprar tarjeta de identificación,
Licencia de conducir real y falsa,
Compre pasaporte real en línea,

Visit Here fpr more information. :- https://permisodeespana.com/licencia-de-conducir-espanola/
Address: 56 Guild Street, London, EC4A 3WU (UK)
Email: contact@permisodeespana.com
WhatsApp: +443455280186

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home