Exforsys.com
 
Home Tutorials C Language
 

C Programming - Constants and Variables

 

C Programming - Constants and Variables - Page 2

Page 2 of 3


.



The identifiers must conform to the following rules.


1. First character must be an alphabet (or underscore)
2. Identifier names must consists of only letters, digits and underscore.
3. A identifier name should have less than 31 characters.
4. Any standard C language keyword cannot be used as a variable name.
5. A identifier should not contain a space.


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



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.




Next Page: C Programming - Constants and Variables - Page 3


Read Next: C Programming Language - Data Types



 

 

Comments


Amit Anjan said:

  ;)hey the content is superb..its too good for the beginners..
August 27, 2006, 9:12 am

Thilina said:

  I really think all this is so incredible coz it is so simple to understand. Now i can bunk classes but still have hope.
Thanks
January 23, 2008, 2:36 pm

Aaj said:

  Hi,
i am beginner and want more explanation,please provide
November 6, 2008, 5:17 am

preeti said:

  the content is fabulus
November 13, 2008, 10:41 am

lalu said:

  i would like to know how to produce a new product by using

c progrmming and vectors and matrices
December 12, 2008, 12:02 am

satheesh.s said:

  hai, i am satheesh ,i am doing mca,these simply enough for beginners ,i want to know the source code for printf and scanf fuctions.
December 22, 2008, 12:21 am

Raman Bhatia said:

  Hi, This is Raman Bhatia From Punjab , its contents too simple that i want to appriciate to the Writer, its too fabulous
December 26, 2008, 1:04 am

Anuj said:

  I really think all this is so incredible coz it is so simple to understand. Now i can bunk classes but still have hope.
January 31, 2009, 5:41 am

Sonu Bhadouria said:

  Its very necessery for the beginner.
February 8, 2009, 12:29 pm

bharathi said:

  i need help to find error
February 9, 2009, 7:31 am

murari said:

  I really have interest for learning the C programming. When the function portion comes, I really confuse. How I can remove it.
thank u
February 13, 2009, 6:04 am

shoujoreader said:

  what kind of error? logical or syntax errors?
logical errors are more hard to debug...

Experts say, programmers are intellectual.
I agree, it's hard to study C programming, it takes a lot time and effort. Maybe because the teaching in our school is hard.
August 21, 2009, 12:14 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape