Wednesday, 7 September 2011

Introduction of C Programming







                               Basic Introduction of  C  Programming

What it  C

                      C is programming language developed at AT & T's Bell Laboratories of USA in 1972.  It was designed and written by a man named Dennis  Ritchie.
                      C is what is called a compiled language. This means that once you write your C program, you must run it through a C compiler to turn your program into an executable that the computer can run (execute). The C program is the human-readable form, while the executable that comes out of the compiler is the machine-readable and executable form. What this means is that to write and run a C program, you must have access to a C compiler. If you are using a UNIX machine (for example, if you are writing CGI scripts in C on your host's UNIX computer, or if you are a student working on a lab's UNIX machine), the C compiler is available for free. It is called either "cc" or "gcc" and is available on the command line.


 Why C  is  Popular 

   
 1 . FLEXIBILITY  :  


' C ' is a general - purpose language . It can be use for diverse applications.The language itself places no constraints on the programmer .


2.POWERFUL  :  


It provides a varity of data types,control - flow instructions for structured progreams and other built in features .

3.SMALL SIZE  :  


' C ' language provides no input / output facilities or file access. These mechanisms are provided by functions. This helps in keeping language small.


4.MODULAR DESIGN :


 The ' C ' code has to be written in functions, which can be limked  with or called in other programs or applications. C also allows user defined  functions to be stored in library filesd and linked to other programs.       


5. PORTABILITY  : 


 A ' C ' program written for one computer system can be compiled and run on  another with little or no modification. 




6. HIGH LEVEL STRUCTURED LANGUAGE FEATURES :


 This allows the programmer to concentrate on the logic flow of the code rathe than worry about the hardware instructions.


7. LOW LEVEL FEATURES : 


' C ' has closed relationship with the assembly language making it easier to write assembly language code in a ' C ' program.


8. BIT ENGINEERING : 


' C ' provides bit manipulation operators which are a great advantage over other languages .


9. USE OF POINTER :


 This provides for machine independent address arithmetic.


10.EFFICIENCY : 


A program written in ' C ' has development efficiency as well as machine efficiency ( i.e. faster to execute )







Start with C    
                 
                      Steps in learning  C Language. 
                    
                     1.  Alphabets,Digits,Special Symbols
                     2. Constants variables, keywords
                     3. Instructions 
                     4. Program

                       


Program Development Cycle
     


   














Sample of C Programs 




                 1. To display the following message  C  on the screen 
                      Hello !
                      Welcome to C


             Program 


                           1.  /*  My First C program  */
                           2.        
                           3.  # include < stdio.h >
                           4. main (  )    
                           5.   {  

                           6.         printf ( " Hello ! \n Welcome to C   " );
                           7.    }


           Output 
                           
                   Hello !
                   Welcome to C
  


           Explanation 

  1. Line 1 is a'C 'comment . A comment is used to give additional information about the                   program. It has to be enclosed in /* and */ comment are ignored by compiler . 
  2. Line  2 is a blank line. A program can contain any number of blank lines. This improve readability of  program.
  3. Line 3 is the link section and it tells the compiler to include information about the  specified file. Here the file used is standard input output ( stdio.h). This library  contains predefined input output functions.
  4. Line 5 and 7 are opening and closing braces of main. These braces contain the instruction to be executed 
  5. Line 6 is the only statement in the function . It is a call to another function called printf, which is an output function It's job is to display the provided information on the screen.
  6. The sequence of characters enclosed in " " is called a string which is displayed on the screen.
  7. \ n is a special character called the newline character .This character advances the output to the next line                                                                                
                                                                                                                                                             



Earn upto Rs. 9,000 pm checking Emails. Join now!