Introduction to C Programming Language
In this article, I am going to give you a brief introduction to the C Programming Language. Please read our previous article where we discussed Platform Dependency in C Language. As part of this article, I am going to discuss the following pointers in detail.
- What is C Language?
- Why C execution is faster?
- Is C platform-dependent?
- Why C?
- Is C preferred for competitive programming?
- Why C Language Becomes very Popular:
- Advantages and Disadvantages of C.
- Applications of C Language.
- Features of C Programming Language.
- Characteristics of C Language
- How does C Program work?
What is C Language?
- C is a high-level/middle-level language.
- C is a compiler-based programming language.
- It is a general-purpose language.
- It is a procedure-oriented programming language.
The C Programming Language is a High-Level procedure-oriented structured programming language. Programming Language which is syntactically similar to English and easy to understand is called High-Level Programming Language. When programming language supports module or function implementation then it is called Procedure Oriented Language. Programming Language which follows the TOP-DOWN approach in the form of blocks is called Structured Programming Language.
C is a general-purpose, high-level evergreen, and non-exhaustive programming language that was originally developed by Dennis M. Ritchie in the year 1972 to develop the UNIX operating system at Bell Labs. It is one of the most simple, popular, and flexible programming languages. It was derived from the B language.
It is a machine-independent, structured programming language which is used extensively nowadays to develop various types of applications.
C is a multi-purpose/general-purpose programming language?
Using C language, we can design the applications like
- Operating system. Example: dos, Unix, Linux, windows, android, etc.
- Editors. Example: Notepad, WordPad, MS-word, etc.
- Translators. Example: compiler, interpreter, assemble, etc.
- Commercial applications. Example: hotel / super market / college program, etc.
- Database. Example: oracle, SQL Server, My SQL, SQLite, etc.
- Device drivers. Example: audio / video / printer / keyboard /mouse drivers etc.
- Media players. Example: VLC Media Player, Windows Media Player, MX Player, etc.
- Anti-virus. Example: Avast, Norton, MacAfee, etc.
- Embedded applications. Example: Tv / ac / atm programs, etc.
- PC & Mobile games
- Browsers. Example: I.E, Chrome, Firefox, etc.
- Standalone applications. Example: Calculator, Anti-virus, Browsers, Media players, etc.
C is a procedure-oriented programming language [POP]:
Every programming language is having a particular programming structure, which is called programming paradigm [structure].
Before c language, the languages are following a monolithic program structure. In this, the entire program is designed by using a single program. Due to this, it is very difficult to trace the errors and it is going to more memory. Hence the performance is low.
To avoid this problem in the c language a big program is divided into several small programs called subprograms or subroutines or procedures or functions.
- Modularity: Dividing a big program into several small modules based on program requirements.
- Simplicity: easy to read/understand
- Reusability: write once, use many times.
- Efficiency: performance is high
C is a pop language
C++, python – pop & oop: multi-paradigm
Java, C# – oop
When a language is following more than one programming structure then it is called muti-paradigm.
Why C language execution is faster?
The C Programming language execution is faster as compared to other high-level programming languages such as Java or C#. The reason is, C language doesn’t require the abstraction layer such as JVM (Java Virtual machine in Java) or CLR (Common Language Runtime in C#). C language directly is compiled and executed on top of the operating system.
Is C programming language platform-dependent?
The c programs are platform-independent but the c executable files are platform-dependent. That means you can write a C program on any platform and can also compile it anywhere. But, once you generate executable files on one platform then you can not run that executable files on other platforms. For example, if you generate the executable files on windows, then you can run only those files on the Windows Operating system but on Linus or any other operating system. You need to re-compile the same program in Linus or any other operating system to get that particular operating system executable files.
Why Learn C Language?
Programming Language C was highly recommended for beginners as it is the base language for many other programming languages. Again C was recommended to understand the basic programming concepts such as data types, operators, control statements, and many more in a clear and precise manner. The Syntax and semantics of the C language were easy to understand and nearly the same as widely used modern programming languages such as C++, Java, and C#. So, learning ‘C’ as the main language will play an important role while studying other programming languages.
Is C preferred for competitive programming?
Yes, In recent years competitive programming (Codechef, HackerRank, TopCoder, SPOJ) gained huge popularity among young programmers. Companies such as Amazon, Google, Microsoft, Facebook want a programmer to be good at Data Structures and Algorithms.
C++ the successor of the C language is highly recommended for competitive programming because, In competitive programming, high priority will be given to both space and time complexity.
Why C Language Becomes Very Popular?
- It is one of the legacy programming languages and you can learn it quickly.
- The C language is reliable, flexible, simple, and most importantly easy to use.
- It is based on structured language.
- The C language is considered the mother of all other programming languages.
- Most of the Modern programming concepts are inherited from the C language.
- Most of the Universities preferred to add C programming in their courseware.
Advantages of C Language:
- Platform Dependent: As we copy the .exe file to any other computer which contains windows OS then it works properly because native code is the same. But when the same .exe file if we are copying to any other computer which contains UNIX/LINUX OS then it doesn’t work because the native code is different. This behavior is called Platform Dependency.
- Portability: We can carrying the instruction from one system to another system.
- Easy: C Language code or syntax is very easy to understand. It uses a keyword like if, else, switch, main, etc. This kind of keyword we all are using in our day-to-day life to get some decisions.
- Fast: C compiler is very fast as compared to other language compilers. C compiler can compile around 1000 lines of code in a second. It is more efficient than unstructured code because of the minimized branching of the code.
- Readability: Maintenance of the C code is easy due to the readability of the code.
- Secured: C program is secured.
Disadvantages of C Language:
- C does not have the OOPS feature that’s why C++ is developed.
- There is no runtime checking in C Programming Language.
- There is no strict type checking (for example we can pass an integer value for the floating data type).
- As the program extends it is very difficult to fix the bugs.
- C doesn’t have the concept of the namespace, constructors and destructors, Inheritance, Polymorphism, Abstraction, and Encapsulation like Object-Oriented Programming Language (OOPS).
What are the applications of C Language?
- C is used to develop System software applications like UNIX, WINDOWS, LINUX, and COMPILER DESIGNING.
- C is also used in the development of many applications like commercial products.
- C is used in the development of Embedded and Mobile Apps.
- C Language has good interaction with Hardware.
- Graphic Frameworks for mobile and PC games are developed using C Language.
Features of C Programming Language
It is a very simple and easy language, C language is mainly used for developing the desktop-based application. All other programming languages were derived directly or indirectly from C programming concepts. This language has the following features:
- It is a multi-purpose language. Using C, we can design both system & application software.
- C is a procedure-oriented programming language [POP]
- C comes with a rich [more] set of operators.
- C comes with several predefined / library / built in Example: printf(), scanf(), clrscr(), etc.
- C supports user defined functions. Example: fact(), prime(), armstrong(), etc.
- Dynamic memory allocation.
Characteristics of C Language
- C supports 44 Operators, 32 Keywords, and 14 Separators.
- C is a Case Sensitive Language.
- Every C statement ends with a semicolon (;).
- C language supports a large set of library functions.
- C is a Function Oriented, Procedure Oriented, and Structure Oriented Programming Language.
How does C Program work?
- First, the source code is formed or created (through vi or cd command in UNIX). It is saved with an extension .c, which is known as the source file. For example ked.c
- The second step is to compile the source code, to check for existing errors (through cc command in UNIX or through Alt+F9 in Turbo C). After compilation, if it is free from errors then the object file is generated, which has the extension .o (in UNIX) or .obj (in Turbo C).
- The next step is to link the file to existing files (which is automatically done after compilation in UNIX), which generates the executable files .exe (in Turbo c) or stored in a.out (in UNIX, that always gets overwritten, which can be avoided by renaming the file a.out to some other name).
- The last step is to run or execute the program (through ./a.out in UNIX or through Ctrl+F9 in Turbo C).