Sunday, 23 June 2013

syntax of variable

syntax:
                       

datatype v1,v2,v3.......
 

  • datatype refers to the type of the data i.e integer,float,character,double.....
  • v1,v2,v3...are the names of the variables variables are seperated by commas
  • a declaration statement end with semicolon
  • declaration of the variable is usually done immediately after the opening brace of the pgm
  • the variable can also be declared out side(either before or after) the main function


  

Saturday, 22 June 2013

variable


  • an identifier whose value is allowed to change during the creation of a program is called variable
  • every variable must be individually declared before it can appear in the program
  • the variable declaration establishes the fact the the identifier is a variable and  specifies the type of variable
rules for constructing variable:
  1. a variable name is any combination of 1 to 8 alphabets,digits,or underscores
  2. the first character in the variable name must be alphabet
  3. no commas or blanks are allowed within the variable name
  4. on special symbol other than an under score can be used in a variable name
  5. ex:si ine ,area,radius,marks1,sub marks

identifiers


                                              identifiers


  • identifiers are the names used for variables.types function and label in program
  • they must differ in spelling and case from the keywords
  • these are created by specifying it in the declaration of a variable type or function
rules for identifiers:
    1. first character must be alphabet
    2. must consists of only letters,digit,underscore
    3. only first 31 characters are significant
    4. cannot use a keyword
    5. must not contain white space
                                           

Keywords and identifiers

                                                                   keywords
every c word is classified as either a keyword or an identifier all keyword have fixed meanings and these meanings cannot be changed keywords sever as basic building blocks for program statements
keywords are words whose meaning has already been explained to the c-compiler
the keywords can not used as variable names




autodoubleintstruct
breakelselongswitch
caseenumregistertypedef
charexternreturnunion
constfloatshortunsigned
contionueforsignedvoid
defaultgotosizeofvolatile
doifstaticwhile

C-tokens

in a passage of text individual words and punctuation marks are called as token similarly in a c-program the similarly in a c- program the smallest individual units are known as c-tokens c-tokens are of 6 types
1.keywords
2.identifiers
3.constants
4.strings
5.special symbols
6.operators








       

getting started with c

communicating with a computer involves speaking the language the computer understand which immediately rules out English as the language of communication with computer however there is close analogy between learning c language





Alphabets  -->Words   -->  Sentenses -->paragraph                                        
                         

learning c is similar and easier in order to write a program a in c we must know first what alphabet, numbers and special symbols are used in c then how by using them constants variables are constructed and finally how they are combined to form an instruction a group of instruction would be combined later on to form a program


alphabets/digits/special symbols --> constants /variables/keywords-->instruction-->program