YASH
CONSTANT AND
VARIACLES
IN C
http://alltypeim.blogspot.in/
CONSTANT
CONSTANTS
NUMERIC CHARACTER
INTEGER REAL
STRING
CHARACTER
SINGLE
CHARACTER
http://alltypeim.blogspot.in/
INTEGER CONSTANT
• IT IS REFERS TO A SEQUNCE OF DIGITS
• THERE ARE THREE TYPES :-
(1) DECIMAL INTEGER
(2) OCTAL INTEGER
(3) HRXADECIMAL INTEGER
http://alltypeim.blogspot.in/
• (1):- DECIMAL INTEGERS CONSIST OF A SET OF
DIGITS, O THROUGH 9, PRECEDED BY AN OPTIONAL
- OR + SIGN.
EX= 123 -321 0 654321 +78
EMBEDDED SPACES, COMMAS, AND NON DIGIT
CHARACTERS ARE NOT PERMITTED BETWEEN DIGTS.
EX= 15 750 20000 $1000
http://alltypeim.blogspot.in/
• (2):- AN OCTAL INTEGER CONSTANT CONSIST OF ANY
COMBINATION OF DIGITS FROM THE SET 0 THROUGH 7,
WITH A LEADING 0.
EX = 037 0 0435 O551
• (3):- A SEQUENCE OF DIGITS PRECEDED BY 0X IS
CONSIDERD AS HEXADECIMAL INTEGER. THEY MAY ALSO
INCLUDE ALPHABETS A THROUGH F OR A THROUGH F
REPRESENT THE NUMBERS 10 THROUGH 15…
EX = 0X2 OX9F OXbcd 0x
We rarely use octal and hexadecimal numbers in
programming http://alltypeim.blogspot.in/
REAL CONSTANT
• INTEGER NUMBER ARE INADEQUATE TO REPRESENT
QUANTITES THAT VERY CONTINUOUSLY ,SUCH AS AS
DISTANCES,HEIGHTS,TEMPERTURES,PRICES AND SO
ON..SUCH NUMBERS ARE CALLED REAL CONSTANTS..
EX= 0.0083 -O.75 435.36 +247.0
• The mantissa is either a real number expressed in
exponential notation an integer. The letter separating the
mantissa and the exponent can be written in either lower
case or upper case .
ex= 0.65e4 12e-2 1.5e+5http://alltypeim.blogspot.in/
• Example of numeric consatant
Constant valid?? Remarks
698354L yes represent long integer
2500 no comma is not allowed
+5.0E3 yes (ANSI C supports unary
plus)
http://alltypeim.blogspot.in/
SINGLE CHARACTER CONSTANT
• A SINGLE CHARACTER CONSTANT COTAINS A SINGLE
CHARACTER ENCLOSED WITHIN APAIR OF SINGLE QUOTE
MARKS .
EX= ‘5’ ‘X’ ‘;’ ‘ ’
• note that the character constant 5 is not the same as the
number 5
printf(“%d”, ’a’ );
Would print the number 9, the ASCII value of the letter a.
• Since each character constant represents an integer value
it is also possible perform arithmetic operations
http://alltypeim.blogspot.in/
Single constant
• A sting constant is a sequence of characters
enclosed in double quotes. The character may be
letters , numbers, special character and blank space
are ex =“hello!” “1987 “
• Remember that a constant is not equivalent to the
single string constant . Character strings are often
used in programs to build meaningful programs
http://alltypeim.blogspot.in/
BACKSLASH CHARACTER
• C supports some special backslash character that
are used in output function . For example ,the
symbol ‘n’ stands for newline character.
• Note that each one of them represents one
character , although they consist of two
characters.
• these characters combinations are know as escape
sequence
http://alltypeim.blogspot.in/
• CONSTANT MEANIG
a audible alert
b back space f
form feed
n new line
r carriage return
t horizontal tab
v vertical tab
‘  ” single quote
‘  “’ double quote
? question bank
 back slash
0 null
http://alltypeim.blogspot.in/
VARIBLES
• A variable is a data name that may be used to store
data value. Unlike constant that remain unchanged
during the execution of a program ,a variable take
different values at different times during execution.
• a variable name can be chosen by the programmer
in a meaningful way so as to reflect its function or
nature in the program ..some example
average counter_1
height class_strength
total http://alltypeim.blogspot.in/
• As mentioned earlier ,variable , names may consist
of letters ,digits and the underscore (_) character ,
subject to the following conditions;
(1) They must begin with a letter .some systems
permit underscore as the first character.
(2) ANSI standard recognizes a length should not be
normally more than eight characters since only the
first eight characters are treated as significant by
many compilers
(3) Uppercase and lowercase are significant. That is
,the variable Total is not the same as total or
TOTAL http://alltypeim.blogspot.in/
(4) It should not be a keyword.
(5) White space is not allowed
• Examples of variable names
variable name valid ?? Remark
first_tag valid
char not valid chair is a
keyword
Int _type valid keyword may
http://alltypeim.blogspot.in/
• If only the first eight characters are recognized by a
compiler ,then the two names
average_height
average_weight
mean the same thing to the computer such names
can be rewritten as
avg_height and avg_weight
ht_average and wt_average
With out changing their meaningshttp://alltypeim.blogspot.in/
http://alltypeim.blogspot.in/

Constant and variacles in c

  • 1.
  • 2.
  • 3.
    INTEGER CONSTANT • ITIS REFERS TO A SEQUNCE OF DIGITS • THERE ARE THREE TYPES :- (1) DECIMAL INTEGER (2) OCTAL INTEGER (3) HRXADECIMAL INTEGER http://alltypeim.blogspot.in/
  • 4.
    • (1):- DECIMALINTEGERS CONSIST OF A SET OF DIGITS, O THROUGH 9, PRECEDED BY AN OPTIONAL - OR + SIGN. EX= 123 -321 0 654321 +78 EMBEDDED SPACES, COMMAS, AND NON DIGIT CHARACTERS ARE NOT PERMITTED BETWEEN DIGTS. EX= 15 750 20000 $1000 http://alltypeim.blogspot.in/
  • 5.
    • (2):- ANOCTAL INTEGER CONSTANT CONSIST OF ANY COMBINATION OF DIGITS FROM THE SET 0 THROUGH 7, WITH A LEADING 0. EX = 037 0 0435 O551 • (3):- A SEQUENCE OF DIGITS PRECEDED BY 0X IS CONSIDERD AS HEXADECIMAL INTEGER. THEY MAY ALSO INCLUDE ALPHABETS A THROUGH F OR A THROUGH F REPRESENT THE NUMBERS 10 THROUGH 15… EX = 0X2 OX9F OXbcd 0x We rarely use octal and hexadecimal numbers in programming http://alltypeim.blogspot.in/
  • 6.
    REAL CONSTANT • INTEGERNUMBER ARE INADEQUATE TO REPRESENT QUANTITES THAT VERY CONTINUOUSLY ,SUCH AS AS DISTANCES,HEIGHTS,TEMPERTURES,PRICES AND SO ON..SUCH NUMBERS ARE CALLED REAL CONSTANTS.. EX= 0.0083 -O.75 435.36 +247.0 • The mantissa is either a real number expressed in exponential notation an integer. The letter separating the mantissa and the exponent can be written in either lower case or upper case . ex= 0.65e4 12e-2 1.5e+5http://alltypeim.blogspot.in/
  • 7.
    • Example ofnumeric consatant Constant valid?? Remarks 698354L yes represent long integer 2500 no comma is not allowed +5.0E3 yes (ANSI C supports unary plus) http://alltypeim.blogspot.in/
  • 8.
    SINGLE CHARACTER CONSTANT •A SINGLE CHARACTER CONSTANT COTAINS A SINGLE CHARACTER ENCLOSED WITHIN APAIR OF SINGLE QUOTE MARKS . EX= ‘5’ ‘X’ ‘;’ ‘ ’ • note that the character constant 5 is not the same as the number 5 printf(“%d”, ’a’ ); Would print the number 9, the ASCII value of the letter a. • Since each character constant represents an integer value it is also possible perform arithmetic operations http://alltypeim.blogspot.in/
  • 9.
    Single constant • Asting constant is a sequence of characters enclosed in double quotes. The character may be letters , numbers, special character and blank space are ex =“hello!” “1987 “ • Remember that a constant is not equivalent to the single string constant . Character strings are often used in programs to build meaningful programs http://alltypeim.blogspot.in/
  • 10.
    BACKSLASH CHARACTER • Csupports some special backslash character that are used in output function . For example ,the symbol ‘n’ stands for newline character. • Note that each one of them represents one character , although they consist of two characters. • these characters combinations are know as escape sequence http://alltypeim.blogspot.in/
  • 11.
    • CONSTANT MEANIG aaudible alert b back space f form feed n new line r carriage return t horizontal tab v vertical tab ‘ ” single quote ‘ “’ double quote ? question bank back slash 0 null http://alltypeim.blogspot.in/
  • 12.
    VARIBLES • A variableis a data name that may be used to store data value. Unlike constant that remain unchanged during the execution of a program ,a variable take different values at different times during execution. • a variable name can be chosen by the programmer in a meaningful way so as to reflect its function or nature in the program ..some example average counter_1 height class_strength total http://alltypeim.blogspot.in/
  • 13.
    • As mentionedearlier ,variable , names may consist of letters ,digits and the underscore (_) character , subject to the following conditions; (1) They must begin with a letter .some systems permit underscore as the first character. (2) ANSI standard recognizes a length should not be normally more than eight characters since only the first eight characters are treated as significant by many compilers (3) Uppercase and lowercase are significant. That is ,the variable Total is not the same as total or TOTAL http://alltypeim.blogspot.in/
  • 14.
    (4) It shouldnot be a keyword. (5) White space is not allowed • Examples of variable names variable name valid ?? Remark first_tag valid char not valid chair is a keyword Int _type valid keyword may http://alltypeim.blogspot.in/
  • 15.
    • If onlythe first eight characters are recognized by a compiler ,then the two names average_height average_weight mean the same thing to the computer such names can be rewritten as avg_height and avg_weight ht_average and wt_average With out changing their meaningshttp://alltypeim.blogspot.in/
  • 16.