c language keywords,variables &constants
-
Upload
jugain-varma -
Category
Documents
-
view
226 -
download
0
Transcript of c language keywords,variables &constants
-
7/31/2019 c language keywords,variables &constants
1/13
CONSTANTS,KEYWORDS,VARIABLES &LITERALS
-
7/31/2019 c language keywords,variables &constants
2/13
PRESENTED BY :
-
7/31/2019 c language keywords,variables &constants
3/13
C is a programming languagedeveloped at AT& Ts BELLlaboratories of USA in 1972
It was designed & written by aman named DENNIS RITCHIE
In the late 70s C began to replacethe more familiar languages ofthat time like PL/I,ALGOL
-
7/31/2019 c language keywords,variables &constants
4/13
A constant is an entity that doesnt change ,whereas, a variable is an entity that maychange
Types of constants:
a)Primary constants
b)secondary constants
-
7/31/2019 c language keywords,variables &constants
5/13
Keywords are the words whose meaning hasalready been explained to the C compiler (orin a broad sense to the computer).
The keywords cannot be used as variablenames because if we do so, we are trying toassign a new meaning to the keyword. whichis not allowed by the computer. some C
compilers allowed by the computer. Some Ccompilers allow you to costruct variablenames that exactly resemble the keywords.
-
7/31/2019 c language keywords,variables &constants
6/13
Keywords of C programming
AutoBreak
CaseCharConstContinueDefaultDo
doubleelse
enumexternFloatForgotoif
intlong
registerreturnshortsignedsize ofstatic
structswitch
typedefunionunsignedvoidvolatilewhile
-
7/31/2019 c language keywords,variables &constants
7/13
C constants
Primary
constants
Secondary
constants
Integerconstant
Real constant
Characterconstant Stringconstant
ArraysPointers
StructureUnionEnum
-
7/31/2019 c language keywords,variables &constants
8/13
1. REAL CONSTANT :
It must have at least one digit. It must have a decimal point which may be positive or
negative. Use of blank space and comma is not allowed between
real constants.
Example:+194.143, -416.41
2. INTEGER CONSTANT :
It must have at least one digit.
It should not contain a decimal place. It can be positive or negative. Use of blank space and comma is not allowed between
real constants. Example: 1990, 194, -394
-
7/31/2019 c language keywords,variables &constants
9/13
3. CHARACTER CONSTANT :
It is a single alphabet or a digit or a special symbolenclosed in a single quote.
Maximum length of a character constant is 1. Example:
'T', '9', '$'
4. STRING CONSTANT : It is collection of characters enclosed in double quotes.
It may contain letters, digits, special characters andblank space.
Example:
"Techno well Web Solutions, Sangli"
-
7/31/2019 c language keywords,variables &constants
10/13
An entity that may vary during program executionis called a Variable
Variables names are names given to locations inmemory
This locations can contain integer, real or characterconstants.
For Eg:
An integer variable can hold only an integer
constant, a real variable can hold only a realconstant & a character variable can hold only acharacter constant.
-
7/31/2019 c language keywords,variables &constants
11/13
a) A variable name in any combination of 1 to31 alphabets , digits or underscores. somecompilers allow variable names whoselength could be up to 247 characters.still, it
would be safer to stick with the rule of 31characters. Do not create unnecessarily longvariable names as it adds to your typingeffort
b) The first character the variable name mustbe an alphabet or uderscore
-
7/31/2019 c language keywords,variables &constants
12/13
c) NO commas or blanks are allowed within
variable named) No special symbol other than a underscore
be used in a variable name
for Eg:
si_int
m_hra
pop_e_89
-
7/31/2019 c language keywords,variables &constants
13/13