Monday, 24 June 2013
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
- a variable name is any combination of 1 to 8 alphabets,digits,or underscores
- the first character in the variable name must be alphabet
- no commas or blanks are allowed within the variable name
- on special symbol other than an under score can be used in a variable name
- 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
- first character must be alphabet
- must consists of only letters,digit,underscore
- only first 31 characters are significant
- cannot use a keyword
- 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
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
| auto | double | int | struct |
| break | else | long | switch |
| case | enum | register | typedef |
| char | extern | return | union |
| const | float | short | unsigned |
| contionue | for | signed | void |
| default | goto | sizeof | volatile |
| do | if | static | while |
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
Subscribe to:
Posts (Atom)

