Saturday, 29 June 2013
escape sequence characters
- escape sequences are used in formatting input and output
- an escape sequences always begins with a backward slash and is followed character
- c supports some special escape sequence characters that are used to do special task
- these are also called as backslash characters
- some of the escape sequence characters are as follows:
character constant | meaning |
---|---|
\n | new line |
\b | backspace |
\t | horizontal tab |
\f | form feed |
\a | alert |
\r | carriage return |
\v | verticaltab |
\? | question mark |
\' | single quote |
\" | double quote |
\\ | backslash |
\0 | Null |
Monday, 24 June 2013
interger,floating point,character constants
interger constants:
integer constants take one of the following forms:
integer constants take one of the following forms:
- a decimal number e.g 1,123,100002.
- an octal number e.g.,01,01273,0303242.anoctal constant is introduced by a leading 0 and the digits are 0 through 7
- a hexadecimal number e.g.,0X1,0X7b,0X186A2.a hex constant is introduced by a leading 0Xor 0x and the digits are 0 trough 9 followed by a through F
- a character constant
floating point constants take one of the following forms:
- a decimal number followed by a decimal point followed by another decimal number e.g.,1.0,1.9993,3.42
- a number like the previous but with an exponent part i.e an e or E followed by a decimal number e.g 1.0e10,1.23e-2,1.00e+2
- A character constant is a character enclosed in single quotes e.g, 'a','2'
- in a character constant a backslash character is treated specially it introduces an escape sequence
- these escape sequences are usually used to represent characters that are not easy to see when represented by themselves or need to be escaped for syntax reason
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
Tuesday, 28 May 2013
The C character set
A character denotes any alphabet digit or special symbol used to represent information the valid alphabets, numbers and special symbols allowed in c
Alphabets A,B..........Z
a,b,...........z
digits 0,1,2,3,4,5,6,7,8,9
special symbols `'!@#%^&*()_+=?/;:'"<>,.
Alphabets A,B..........Z
a,b,...........z
digits 0,1,2,3,4,5,6,7,8,9
special symbols `'!@#%^&*()_+=?/;:'"<>,.
What is C
c is a programming language developed at AT & T's Bell laboratories of usa in 1972. it was designed and written by a man named Dennis Ritchie . In the late seventies C began to replace the more familiar languages of the time like Pl/I,ALGOL etc no one pushed C it wasn't made the official bell labs language thus with our any advertisement c reputation spread and its pool of users grew . Ritchie seems to have been rather surprised that so many programmers preferred c to older languages like FORTRAN the newer ones like pascal and APL .
Subscribe to:
Posts (Atom)