Introduction to C Programming
Our daily life revolves around computers and their programs. All programs fulfill one or the other user’s requirement. The necessity of the user varies to wide range from displaying some information, performing calculations to storing and retrieving the data. But not one single program can fulfill all these needs of the users. Hence we have different categories of techniques and programs in computer world. Each one of them has its own features and capabilities to achieve the user needs. For example, Java is mainly used to design the websites / UIs, while SQL is used for querying the data stored in the database. At the same time there is another category of requirement, which mainly deals with providing different functionalities to the users – may be displaying some useful information, or performing some calculations or some kind of programming. For example, consider a microwave machine in which we set the time so that the food is cooked. This microwave is not limited for setting the timer for cooking; it gives variety of functionalities to set for the food to be cooked. Did you ever wonder how it works? It all works based on the internal programming fed to it. Similar example of programming would be refrigerators where we set different temperatures for different sections inside it, washing machines where we feed the time, type of cloths, weights of the cloth, type of water to be used etc; which in turn performs the tasks for us. All these are based on the programming done on it. In order to perform all these tasks within a machine, we need a powerful and high performing programming language. This requirement to our real world necessity made developers to use C programming language.
Main features of C Language are :
- Easy to Learn! – Each and everyone’s first priority is ‘Easy’.
- Structured Language – It is a structured language. In this language, each set of code is different structures and each structure is not known to the other structure unless and until it has been called or used. That means, it does not mix the entire programming and user requirement into one block or function. It clearly separates different functionality into different set of functions and gives the easiness to understand the program. For example, consider a program which does different arithmetic operations. In C, rather than performing all addition, subtraction, multiplication and division one by one, it gives the functionality to have different functions for addition, subtraction, multiplication and division. Hence user can call only those functions that are required to be called. Else, all the operations will be performed irrespective of user’s requirement. Hence it makes the program efficient too.
- Unlike other programming languages, it can be compiled on different computer platforms. This is one of the most popular advantages of using C language.
- It is a middle level language – it uses some features of high level languages which are mainly used as user oriented language for faster developments and some features of low level language which is mainly used as machine oriented language for faster executions. Hence C holds good for both development as well as performance. Hence it is efficient for programming any machines, games, mobiles apps etc. To be more specific, because of this feature of C, UNIX operating system is coded in C. Hence UNIX is faster and efficient. Efficiency of RDBMS language MySQL is due to its underlying C program!
- C can act as different system programs like editors, language compilers, operating systems, assemblers, print spoolers, network drivers, databases, interpreters, utilities, or even as a modern language. All these capability is obtained only one language – that is C Language. This makes C as one of the strongest language.
These are the main features of C language for its popularity. When we look deep into C programming techniques, we get even more features that make it even more strong.
- It is a function oriented programming language. That means, each functionality within the program has been coded within its own function and is called by any other functions depending on requirement. Hence it makes any one viewing the program to understand it easily, makes the developer to develop the code independently, call the functions as and when required.
- It provides very good set of flow control with very limited number of keywords like for loops, while loops, do/while loops, if clause and switch case.
- It provides arithmetic as well as logical operators to perform different calculations.
- It has a very strong feature called pointers which makes it very unique from any other programming language. Pointers make it to access the low level access to the memory addresses.
- Strings, Array, structures, unions, enumerations etc are other key features of C, which makes it popular.
- It allows user defined datatypes by using typedef.
- It allows inclusion of other programs into current program. That means, if we need to re-use any other compiled programs in our current program, then it can be done by defining the preprocessor directives. This makes the code shorter as well as reusing the codes.