By: Nithya Suresh in C Tutorials on 2008年07月05日 [フレーム]
A character denotes any alphabet ,digit or symbols to represent information.The following are the valid alphabets, numbers and special symbols permitted
in C
Numerals: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Alphabets: a, b, ….z
A, B, ……...Z
Arithmetic Operations: +, -, *, /, %(Mod)
Special Characters:
CONSTANTS, VARIABLES AND KEYWORDS
A ‘constant’ is an entity that does not change, but a ‘variable’ as the name suggests may change. We do a number of calculations in a computer and the computed values are stored in some memory spaces. Inorder to retrieve and re-use those values from the computer’s memory locations they are given names. Since the value stored in each location may change, the names given to these locations are called as ‘variable names’.
Constants:
There are mainly three types of constants namely: integer, real and character constants.
Integer Constants:
The integer constants
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
214 213
212 211 210
29 28 27 26
25 24
23 22
21 20
= 1*1 + 4*1 + 8*1 + 16*1 + 32*1 + 64*1 + 128*1 + 256*1 +
512*1 + 1024*1 + 2048*1 + 4096*1 + 2*1 + 8192*1 + 16284*1
= 32767 (32767 Bits can be stored for integer constants)
(i) Decimal Integer Constant:
(ii) Octal Integer Constant:
(iii) Hexadecimal Integer:
REAL CONSTANTS:
The real or floating point constants are in two forms namely fractional form and the exponential form.
A real constant in fractional form must:
Ex: +867.9, -26.9876, 654.0
In exponential form, the real constant is represented as two parts. The part lying before the ‘e’ is the ‘mantissa’, and the one following ‘e’ is the ‘exponent’.
The real constant in exponential form must follow the following rules:
Ex: +3.2e-4, 4.1e8, -0.2e+4, -3.2e-4
CHARACTER CONSTANTS
A character constant is an alphabet, a single digit or a single special symbol enclosed within inverted commas. The maximum length of a character constant can be 1 character. Allots 1 byte of memory
Ex: ’B’, l’, ’#’
Types of C Variables
Variable names are names given to locations in the memory. These locations can contain integer, real or character constants. An integer
variable can hold only an integer constant, a real variable can hold only a real constant and a character variable can hold only a character constant.
Rules for Constructing Variable Names
A variable name is any combination of 1 to 31 alphabets, digits or underscores. Some compilers allow variable names whose length could be up to 247 characters.
Ex.: si_int
e_hra
pod_e_81
C compiler makes it compulsory for the user to declare the type of any variable name that he wishes to use in a program. This type declaration is done at the beginning of the program. Following are the examples of type declaration statements:
Ex.: int si, e_hra ;
float bas_sal ;
char code ;
Since, the maximum allowable length of a variable name is 31 characters, an enormous number of variable names can be constructed using
the above-mentioned rules. It is a good practice to exploit this enormous choice in naming variables by using meaningful variable names.
C Keywords
C makes use of only 32 keywords or reserved words which combine with the formal syntax to the form the C programming language. Note that all keywords in C are written in lower case. A keyword may not be used as a variable name.
break
case
char
const
continue
default
do
doubleelse
enum
extern
float
for
goto
if
long
register
return
short
signed
sizeof
static
structswitch
typedef
union
unsigned
void
volatile
while
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in C )
Passing double value to a function in C
Sum of the elements of an array in C
Printing a simple histogram in C
Simple arithmetic calculations in C
Passing pointer to a function in C
Find square and square root for a given number in C
Using memset(), memcpy(), and memmove() in C
Latest Articles (in C)
Simple arithmetic calculations in C
Find square and square root for a given number in C
Printing a simple histogram in C
Sum of the elements of an array in C
Passing pointer to a function in C
Passing double value to a function in C
Infix to Prefix And Postfix in C
Sum of the elements of an array in C
Printing a simple histogram in C
Find square and square root for a given number in C
Simple arithmetic calculations in C
Passing double value to a function in C
Passing pointer to a function in C
Infix to Prefix And Postfix in C
while, do while and for loops in C
© 2023 Java-samples.com
Tutorial Archive: Data Science React Native Android AJAX ASP.net C C++ C# Cocoa Cloud Computing EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Trends WebServices XML Office 365 Hibernate
Latest Tutorials on: Data Science React Native Android AJAX ASP.net C Cocoa C++ C# EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Cloud Computing WebServices XML Office 365 Hibernate