You are on page 1of 17

m Learning steps

m Constants and Variable


m Types of constants and Variables
m How to Identify Types
m Rules for creating Variables
m Keywords
6 

? Learning C# language is similar to learning English


? It begin with Alphabets and digits.
? Alphabets to form words, words to form sentences
and sentences to form paragraph and the process
continues
? Digits forms different numbers.
The following help in building C# language
m Alphabets, Digits and Special Symbols.
m Constants & Variables
m Data Types.
m Keywords
d  

  
 

? C# allows all alphabet irrespective of they are capital


letter i.e A-Z or small case letters .i.e a-z.
? Digit ranging from 0-9.
? 32 special symbol in the keyboard.
‘



? Alphabets, digits and special symbols are combined to


form constants and variables.
? For example 3x+2y where 3and 2 are constants as
their values does not change ,they are also called as
literals.
? variables are x and y as their values changes ,they are
also called as identifiers.
‘


There are three types of Constants.


? Integer Constants
? Real Constants
? Character Constants
à  ‘


? Example of Integer constants are 23, 56, 678 etc.


Rules for creating Integer Constant
m It should not have decimal point.
m It can be either +ve or-ve The default is +ve.

m Within integer constant their should not be comma


and space.
m The valid range of integers constants is -2147483648 to
+2147483647.
÷  ‘


? It must have decimal point present.


? It can be +ve or-ve. The default is +ve.
? There should not be a comma or space within real
constant.
? Valid range of real constants is -3.4*1038 to +3.4*1038
? For example 427.62, -0.00254 can be expressed in the
form 4.2762E2,-2.54e-3 etc.
? The first form is fractional form and second form is
known as exponential form.
‘  ‘


? When a character, digit or special symbol is written


within a pair of single inverted commas form a
character constant.
? It can be capital letter, small case letter, a digit or
special symbol within single inverted commas.
? For example
? ǮZǯ
? ǮNagpurǯ is not a character constant it is string
constants
‘


? String constants are enclosed in double quotes


string message = DzHellodz;
? for example DzNagpurdz.
p
‘


‘    



  

   

  

    

    !"#!$#!#!#!#!#! #!#!!#
!%#!#!&#!‘'()#!*+

^^
‘ p


©   
  
char 0 t0 65535 2
sbyte -128 to +127 1
short -32768 to +32767 2
int -2147483648 to 4
+2147483647
long -9223372036854775808 to 8
+92233720368547758087
float -3.4e38 to +3.4e38 4
double -1.7e308 to + 1.7e308 8

bool True/false 1


? A name given to memory location whose value


changes is called as variable.
? No of variables are equal to no of constants.
? for example
? x=3,y=4
? Z=x+y
„ p

?3 Integer Constant
? 3.0 Real Constant
? Ǯ3ǯ Character Constant

? int a float b char c


? a=3 b=3.0 c=Ǯ3ǯ
? int ,float ,char Ȃdata types /primitives
? a,b,c Ȃ variables
? 3,3.0,ǯ3ǯ Ȃconstants/literals
÷
 

? Cannot begin with a digit


? Rest can be alphabets,digits,underscores or $
? Ex pop98 , si_int
? Any length.
? No commas or spaces.
? Variable names are case sensitives
? for example the following are consider different
variables
? abc ABC Abc aBc AbC
‘  

? Words whose meaning already stands explained to


machines are called as Keywords.
? 77 keywords available in c#.
? int,float and char are keywords
? Reserved are same as keywords.
? Following declaration of variable will not work
? integer a
? real b
? character c
? Ôroper declaration of variable which machine
understands is
? int a
? float b
? char c

You might also like