.:: Welcome To My Personal Blog ::.

Friday, April 22, 2011

Programming with C Tutorial - Part 1

Now-a-days, C is the basic language to learn programming. To learn programming using C is so much easy. Here, the basic things and fundamentals of C programming will be described. Hope it will help the beginners.

C Character Set:

C uses the uppercase letters A - Z,  the lowercase letters a - z,  the digits 0 - 9, and certain special characters
as building blocks to  form basic  program elements (e.g., constants, variables, operators, expressions, etc.).
The special characters are -
+     -     *     /     =     %     &     #     !     ?     ^     "     '     ~     \ 
|     <     >     (     )     [     ]     {     }     :     ;     .     ,     _      (blank space)


Identifiers:
 
Identifiers are  names that are given to various program elements, such  as  variables, functions and arrays.
Identifiers consist of letters and digits,  in  any order, except that  the first character must  be a  letter. Both the uppercase and lowercase letters are permitted.

Examples of valid identifiers:
     name     sum     i     n     avg

Keywords:

Keywords are reserved words that are used and predefined in C. They can not be used as identifiers. Some of them are given below:
auto          extern          sizeof          break          float          static          case
for            struct           char            goto            switch         const        if
typedef     continue       int               union          default         long          unsigned
do            register         void            double        return          volatile     else
short             while          enum           signed

Data Types:

C supports several data types which may be represented differently within the computer's memory. The basic data types with corresponding memory requirements and ranges are given below:
Data Types Description Memory Requirements Range
int integer quantity 2 bytes -32,768 to +32,767
short short integer quantity 2 bytes -32,768 to +32,767
long long integer quantity 4 bytes -214,74,83,648 to +214,74,83,647
float floating-point number 4 bytes
double double-precision floating-point number 8 bytes
char single character 1 bytes -128 to +127

Escape Sequences:

Some non-printing characters, as well as the backslash (\) and the apostrophe ( ' ), can be expressed in terms
of escape sequences. An escape sequence always begins with a backward slash and is followed by one or more special characters. The commonly used escape sequences are listed below.
Character  Escape Sequence  ASCII  Value
bell (alert)               \a                         007
backspace              \b                         008
horizontal tab          \t                          009
vertical tab              \v                         011
newline (line feed)   \n                         010
form feed                \f                         012
carriage return         \r                        013
quotation mark (")   \"                        034
apostrophe (')         \'                         039
question mark (?)   \?                         063
backslash 0)           \\                         092
null                         \0                        000 



Courtesy :
Schaum's Outline of Programming with C - Byron S. Gottfried, 2nd Edition. McGraw-Hill Publications





No comments:

Post a Comment

Popular Posts