Krantesh Singh

Krantesh Blog Featured Images

Understanding a C Program

printf("Hello Worldn");

In this blog post We will try to understand a basic C Language Program and How our computer understand it. So Lets get started.

If you’re from programming background chances are you can understand the given piece of code. Save this piece of code with any file name with .c extension and then compile it and run it to see the output.

Hello World

This is the obvious output you will get. Whats a big deal in this everyone knows it. What are the steps hidden or envolved in producing this output is the thing we’re going to talk about.

In any C Language program there are generally 2 steps involved 1. Compile the Program 2. Run the Program

To understand the step you’re going to need a editor to write the program and compiler to complile the program.

I’ve used VIM as my editor to write the program and GCC, the GNU Compiler Collection and I’m on UBUNTU OS to perform all the steps. You might be on windows or mac. Just install GCC on your machine and you’re goog to go. OS based on Linux are generally have GCC installed already in order to know whether GCC compiler is installed or not go to your terminal and type following command : gcc -v

This command will show you the GCC version installed on your machine. if you’re getting an error then its not installed and you have to install it manually.

We write programs in High Level Language (Language which is understood by Humans). Computer does not understand english. It understand binary numbers which are in form of 0 & 1. So compiling the program generally converts the HLL (High Level Language) to LLL(Low Level Language) so that computer could understand it.