Hello there fellow geeks, I hope you all are doing well. I decided to write about C as it is a basic part of the programming we do in microcontrollers. Sure that is Embedded C which can be termed as “Miniature version” of C as it is basically designed for micro-controllers. I will be starting from basic and intended to go to the advanced level of C.

Environment Setup

So, Let’s get straight into business. For C, you guys will be needing a compiler and you can install that by clicking here. After that, you will be needing an Editor and my favorite text editor is- Sublime Text. You can select any other text editor you want. There are cool IDEs(Integrated Development Environment like CodeBlocks) that are there but I don’t recommend that atleast for now.

You can download and install the compiler and Sublime Text Editor from the following link. Install the compiler and sublime text editor. There are some things that you have to do after the installation of the compiler(only one time though) you have to add the path in your system variable. Please follow this link on how to do that.

Now that you have done that, let’s proceed to write your first program in C-”The Hello World” program.

Your First Program

Open an editor that you have just downloaded. Create a new file and save it in whatever name you want with the “.C” extension. Now just type in the following program into your editor. You can copy the program as well but common-it’s your first program.

DON’T Copy Your First Program, you can copy the second one- Unknown

#include <stdio.h>

int main()
	printf("Hello World..!\n"); 
	return 0;

Let’s understand what you have typed. In the above program, You are just printing the classic-“Hello world” to your screen. The main is the method where the execution of your program starts. The “printf” method prints whatever you type in there, the \n is the newline character. We need this if we have to print in the new line. Let’s now run this code.

Compiling and Executing your Code

Well C is the compile-time language. It first checks that your code has an error or not. For compiling the above code, open your “CMD”  with the path added by the MinGW compiler. Navigate yourself to your folder. Once you reach to your address- just type the following command to compile your program.

g++ <Your file name.c> -o <filename>

If there is no error message, your compilation of the program is over and now is the time to run. For the execution, just type <filename.exe> and your program should be executed. Congratulations- you just made your first program.


Share This