Introduction to C
C is one of the most popular programming language created by Dennis Ritchie at Bell laboratories of American Telephone and Telegraph in 1972. It is designed to create simple and fast programs. The language is something that is closer to what machine understands and that makes it one of the fastest programming languages in the world.
It is structured, medium level programming language. It is most widely used in development of operating systems, drivers and kernels that interacts with hardware directly and embedded systems programming. For learning any new computer programming language it’s always easier if you have basics of C clear. Let’s proceed to features of C.
Why C became so popular
- It is one of the earliest programming language in industry.
- It is very fast compared to other languages.
- Easy to learn.
- Simple to use.
- C is a structured programming language.
- C provides the basic foundation to learn other languages.
Advantages of C
- It combines features of both high level and low level languages.
- It is a structured programming language that allows complex programs to be broken down into simpler programs or so called functions.
- Highly portable, used for scripting drivers, kernels, software applications and major parts of Windows, Linux and Unix operating systems.
- C has a rich library that provides a lot of built-in functions.
- Offers dynamic Memory allocation so memory management is good.
Disadvantages of C
- Does not support Object Oriented Programming (OOPs) concepts.
- No runtime checking in C language.
- It does not provide constructor and destructor.
- Does not provide direct support to error handling or exception handling.
- Doesn’t provide support of namespace like in C++.
Features of C
- Simple and easy to learn.
- C Programs are fast and efficient.
- There is large set of inbuilt functions and libraries that makes easy to write a complex programs simply.
- C is portable means programs written in once can run on different machines with different specifications by little modification.
- C is well suited structured programming language, it requires the user to solve the problem in terms of blocks.
- C program is collection of functions supported by C library, we can also add our own function in C library.
How to run C program
C is a compiled language, means the machine will not interpret the C code directly. So, we need to convert the human readable C code into machine readable machine code.
To compile the human readable C code into machine readable code, a program called Compiler is needed. One of the most popular C compilers is the GNU Compiler Collection or gcc.
- Write the program on your favourite Text Editor.
- Save the file with .C extension.
- Open the terminal and type gcc filename.c –o filename to compile the C program into executable code.
- After that type ./filename to run the C program.
- In case –o filename is not used, than executable file is saved with the name “a”. Than it can be executed using ./a.out in Linux terminal or using a in command prompt.