Introduction to C Language

What is C?

C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It isa very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

Why learn C?

1) It is one of the most popular programming language in the world
2) If you know C, you will have no problem learning other popular programming languages such as Java, Python, C++, C#, etc, as the syntax is similar
3) C is very fast, compared to other programming languages, like Java and Python
4) C is very versatile; it can be used in both applications and technologies

Quickstart for C

Let's create our first C file.
Open Codeblocks (you can open any other software as well) and go to File -> New -> Empty File.
Write the following C code and save the file as myfirstprogram.c (File -> Save)
    #include< stdio.h>
    int main()
    {
       printf("Hello World!");
       return 0;
    }
Don't worry if you don't understand the code above. For now, focus on how to run the code.
In Codeblocks, it should look like this:
C Code
Then, go to Build > Build and Run to run (execute) the program. The result will look something to this:
Output Code
Congratulations! You have now written and executed your first C program.

Advantages of C :

  • C language is a building block for many other currently known languages. C language has variety of data types and powerful operators. Due to this, programs written in C language are efficient, fast and easy to understand.
  • C is highly portable language. This means that C programs written for one computer can easily run on another computer without any change or by doing a little change.
  • There are only 32 keywords in ANSI C and its strength lies in its built-in functions. Several standard functions are available which can be used for developing programs.
  • C language is a structured programming language. This makes user to think of a problem in terms of function modules or blocks. Collection of these modules makes a complete program. This modular structure makes program debugging, testing and maintenance easier.
  • Disadvantages of C :

  • C does not have concept of OOPs, that’s why C++ is developed.
  • There is no runtime checking in C language.
  • There is no strict type checking. For example, we can pass an integer value.
  • C doesn’t have the concept of namespace.
  • C doesn’t have the concept of constructor or destructor.
  • What To Avoid in C :

  • Mixing signed and unsigned integers
  • Reading an array out of bounds
  • Using void for generic pointers to memory
  • Missing out the Base Condition in Recursive Function