Beginning with C Programming Language
|1. What is C Programming Language?
C is a high-level, general-purpose, procedure-oriented programming language that was developed at AT & T’s Bell Laboratories of the USA in 1972 by Dennis Ritchie. It was used to re-implement the UNIX operating system. Because of its simplicity and reliability, it started replacing the popular languages of that time like PL/I, ALGOL, etc. Having survived for more than three decades its popularity keeps varying along with newer Object-oriented languages like Java, C#, python, C++, and other procedure-oriented languages as well.
2. Why use C Programming Language?
An often debatable question that arises here is – “With C already being superseded by languages like C++ and Java, why to bother learning C at all?” The call to C is quite close. Here are a few reasons why –
- A major portion of the trending operating systems like Windows, Unix, Linux still uses C because of its high speed of execution.
- There is a need for fast working systems with a limited amount of memory in the microprocessors that power smart devices like phones, washing machines, digital cameras, etc. C fulfills this primary need for operating systems and programs.
- Popular languages like Java, C++ are object-oriented which has a lot of advantages to offer but learning C first will give a good hold over basic programming concepts.
- Many popular gaming frameworks(like DirectX) make use of the C language. A game needs a fast reaction to the inputs which needless to say, is provided by C.
3. Features of C Programming Language
C programming language comes with a great number of features that make coding easier and simple to use. In this section we shall see a few features of C which make it very user-friendly and readily usable:
3.1. Portability
Portability in C programming language refers to the fact that a code written in C can be used on other platforms too. In a more simple way, programs written in C can be run and compiled on other machines which almost no modification.
3.2. Speed
Due to a varying range of data types and powerful operators, the C programming language is found to be very fast and efficient. It is much faster than BASIC. The C programming language is also known as the middle-level language because it supports system programming due to which it is compiled at a faster rate than other high-level programming languages.
3.3. Compact
C programming language contains many keywords with predefined functions which makes it handier to use C. Instead of using a dozen of lines of code, a simple word or two might perform the operation which we want.
3.4. Modular Programming
Modules refer to the small parts of a large C program. This is an important feature of structural programming. Modules reduce the complexity of a program and make debugging easier without causing any problem in the program structure because all the modules are integrated into the program code.
3.5. Case Sensitive
Case sensitivity refers to a language’s ability to differentiate between the upper case and lower case letters. C programming language is case sensitive which means that C treats ‘continue’ and ‘CONTINUE’ in a different manner. The reason is that UNIX is case sensitive and C was created to be used on UNIX.
3.6. Extensible
C programming is found to be very extensive because it enables a user to produce new language features like new notations, control features, data structure, operations, etc. It allows us to change or modify the language according to our changing needs.
4. First C program – “Hello World!”
Why this Hello World program? This is only to explain the basic structure and syntax of C programming language. We will further learn a lot of syntax and programs in this tutorial series but to start let us make this most simple and basic program that I believe is written by every programmer in whatever language(generally his/her first language).
So, let’s go through a simple Hello World Program to get a better insight into C language.
#include<stdio.h> void main() { printf("Hello World!"); }
Output:-
Hello World!
An explanation of the various parts of the above program:
- #include<stdio.h> – #include is a preprocessor which is here used to insert header file stdio.h. We need to import these files as it includes some functionalities i.e. functions which are already written to be shared among various C programs. stdio.h is a header file which comes along with the compiler.
- void main() – is the main function which contains the set of statements to be executed. This is the method from where the execution of a program begins. no matter whether this function is written in the beginning or end, execution will always start from main().
- printf() – is a library function that displays the formatted output to the screen. Further, we will see how to properly format the output and how to include various variables in the formatted output. Here we pass “Hello World!” as a string to it and it sends the message on the output screen.
Helpful Links
Please follow C Programming tutorials or the menu in the sidebar for the complete tutorial series.
Also for the example C programs please refer to C Programming Examples.
All examples are hosted on Github.
Recommended Books
An investment in knowledge always pays the best interest. I hope you like the tutorial. Do come back for more because learning paves way for a better understanding
Do not forget to share and Subscribe.
Happy coding!! ?