Introduction To C Programming Language

I recently got admitted into the Alx Software Engineering program and I can say, it's been an awesome experience so far. We've learned about the Linux terminal and some awesome stuff. I will be sharing and teaching what I've learned so far on this blog. This article will focus on the introduction to C. Alright, let's get started.

What is C programming language?

c.png

Brief history

C is a general-purpose computer programming language. It was created in the 1970s by Dennis Ritchie and remains very widely used and influential.

By design, C's features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems, device drivers, and protocol stacks, though decreasingly for application software, and is common in computer architectures that range from the largest supercomputers to the smallest microcontrollers and embedded systems. - Wikipedia

C is a low-level programming language used in building different types of software ranging from device drivers to operating systems.

Why C

You might be asking, why do we use the C programming language? Here are the reasons:

  • C is easier to write, and unlike other languages, it's human-friendly.

  • C requires fewer lines of code, thereby making it more efficient.

  • C is portable. I.e., one C code can run on multiple operating systems without having to write different code for different operating systems.

  • C is more efficient in memory management

  • And many more...

How C works

C can be written on any operating system. C uses what is called a compiler to interpret the C code to the binary equivalent. Without a compiler, the computer system will not be able to understand our C code. The compiler goes through 4 phases while interpreting our C code. These are the preprocessor stage, the compiler stage, the assembler stage, and the linking stage.

compilation-process-in-c2.png

Preprocessor Stage

C standard library doesn't include all the code necessary to perform certain operations, so we use external libraries (which are a predefined set of codes written by other programmers but are not included in the C standard library). The preprocessor stage expands those libraries that are included in our C code. it puts the actual c code of those libraries we included in our C program into our C code.

Compiler Stage

In the compiler stage, the C code is converted into assembly code.

Assembler stage

This is the stage where the assembler converts our assembly code into object code

Linking stage

The linking stage is the stage where the object code is linked with all our libraries in our code to generate an executable file.

The executable file (.exe) can now be run and we will see the output.

Conclusion

We have covered some introductory parts to the language C. We've seen the importance and uses of C. We have also discussed how c can convert its source code to machine code through 4 steps. In the next article, we will consider the internal structure of a C Program.