Exforsys.com
 
Home Tutorials C Language
 

C Programming - Constants and Variables

 

C Programming - Constants and Variables - Page 3

Page 3 of 3




Single Character Constants


A Single Character constant represent a single character which is enclosed in a pair of quotation symbols.


Example for character constants are


'5'
'x'
';'
' '


All character constants have an equivalent integer value which are called ASCII Values.


String Constants

A string constant is a set of characters enclosed in double quotation marks. The characters in a string constant sequence may be a alphabet, number, special character and blank space. Example of string constants are


"VISHAL"
"1234"
"God Bless"
"!.....?"


Backslash Character Constants [Escape Sequences]

Backslash character constants are special characters used in output functions. Although they contain two characters they represent only one character. Given below is the table of escape sequence and their meanings.


Constant


Meaning


'\a'


.Audible Alert (Bell)

'\b'


.Backspace


'\f'


.Formfeed

'\n'


.New Line

'\r'


.Carriage Return

'\t'


.Horizontal tab

'\v'


.Vertical Tab

'\''


.Single Quote

'\"'


.Double Quote

'\?'


.Question Mark

'\\'


.Back Slash

'\0'


.Null


Variables

A variable is a value that can change any time. It is a memory location used to store a data value. A variable name should be carefully chosen by the programmer so that its use is reflected in a useful way in the entire program. Variable names are case sensitive. Example of variable names are


Sun
number
Salary
Emp_name
average1


Any variable declared in a program should confirm to the following


1. They must always begin with a letter, although some systems permit underscore as the first character.
2. The length of a variable must not be more than 8 characters.
3. White space is not allowed and
4. A variable should not be a Keyword
5. It should not contain any special characters.


Examples of Invalid Variable names are


123
(area)
6th
%abc




First Page: C Programming - Constants and Variables


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