Wednesday, 8 August 2012

Basics of c





                 
                  For the past 30 years students sought engineering rather than other vocations and diciplines. Of this more students choose computer science and engineering as their career. But many of the students dont know the just simple understandings in the basic c language. C is the basic computer language for all other languages like c++, java etc. So i would like to explain some basic concepts of c in this blog. 
                        
                        We the humans have our languages like English, French, Latin etc. Like this computers have its own language. We use alphabets and words. So our language is considered as High level language. Computers know binarys....ya zeros and ones. Its language is considered as low level language. The invension of computers is to serve the humans. So there should be an intermediate language in which both humans and computers can understand and it should leads to man must give the orders and computers should accomplish the orders. That is the mediam level language. 






C programming language initially developed by Dennis ritchie in the Bell labs.

STRUCTURE OF C LANGUAGE:


                            Structure of c is the protocol i mean rules to the programmer, while writing a c program. The structure of c is given below:


Documentation


Preprocessor statements


Global declaration 


main()


{


local declaration


Program statements


}


                             The whole program is controlled within main() along with the left brace "{" and the right brace "}". If you need to declare local variables and executable program are enclosed within  "{"  and  "}".


Documentation:


                            Documentation section consist of set of command lines giving the name of the program and other details which the programmer would use later.


Preprocessor statements:


                            Preprocessor statements begins with #. It is also called as preprocessor directive. It instruct the compiler to include c preprocessors such as header files and symbolic constants before compiling the program. Compiler is a c program that translates other languages into machine language. Some of the preprocessors are:


Header files:


#include<stdio.h>


#include<conio.h>


#include<math.h>


#include<stdlib.h>


Symbolic constants:


#define P L 3.1412.


#define TRVE 1


#define FALSE 0

   
Global declaration:
             
                         Global variables are declared before main() and they are user defined functions. This global variables can be accessed by all the user defined functions including main().

Main() function:

                          Each and every c program should contain only one main() function. The execution of c program starts from the main function. If the main() is missing the whole program wont execute. Main() function should be written in small(lowercase) letters and it shouldnt terminate with semicolon. Main() function executes all the user defined statements, library files and user defined functions and all the statements should be with in the left and right braces.


Braces:  


                         Every c program should have a pair of curly braces "{" "}". The left brace indicates the begining of the main() function and the right brace indicates the ending of the main() function. It also indicates user defined functions and compound statements.


Local declaration: 


                         All the variables which are included within main() functions are called as local variables. Not only variables, we can also declare arrays, pointers etc. Local variables can be initialized with their corresponding data types. we shall see an example:


Main() 


{


int number;


int x;


float y;


}


User defined functions: 


                           These are subprograms. Generally subprograms is a function and this function is written by the user are called user defined functions. This functions are performed user specific task and and this also contains set of program statements. They may be written before or after the main() function and this is an optional to the programmer.



                           I think this basic concepts are useful to you. See you all in next blog. Thank you. Blogged by Praveen.

                              
google6d851b91794b9d19.html
               


No comments:

Post a Comment