C Programming – Features and Writing Your First C Program

Why Should You Even Care About C?


C Programming – Features and Writing Your First C Program



Let me be honest with you. When I first came across C programming, I thought — why are we learning something so old? But here is the thing: C is the foundation of modern computing. The operating system running on your machine? Very likely written in C. The firmware inside embedded chips? C. Even newer languages borrow ideas from C.


So before we dive into the features and your first program, understand one thing — learning C is not just about writing code. It is about understanding how computers actually think.



What Makes C Special


C is a Procedural Language


Think about how a large company operates. There is a team for design, a team for testing, a team for deployment — each group handles one specific job. The whole system works because the big task is broken into smaller, manageable pieces.


C works exactly the same way.


In C, you break your entire program into smaller units called functions. Each function is written to do one job and one job only. This makes the code easier to write, easier to debug, and much easier to maintain.


Every C program you will ever write is essentially a collection of functions working together.




C Sits in the Middle — The Middle Level Language


You might have heard the terms high-level and low-level languages. Here is a quick way to understand it:


  • High-level language = More abstraction, more user-friendly, less control over hardware (think Python, Java)
  • Low-level language = Less abstraction, more hardware control, much harder to use (think Assembly)

C is neither. It sits right in the middle.


On one hand, C makes programming simple enough for humans to read and write. On the other hand, it also gives you the power to:


  • Access memory directly using pointers
  • Manipulate individual bits using bitwise operators
  • Embed assembly code right inside your C code

This unique combination is why C is the go-to language for writing operating systems, device drivers, kernels, and even game engines.





Rich Library Support


C comes loaded with built-in functions, standard libraries, and header files. Instead of writing every single piece of logic from scratch, you can simply call functions that are already written and tested. This is one of the biggest advantages C offers — you are building on top of a very well-established foundation.



Writing Your Very First C Program


Let's now look at what a basic C program actually looks like and — more importantly — what every single line means.


Here is a simple program that prints a message to the screen:


// This program prints "Hello Engineer" to the console #include <stdio.h> int main() { printf("Hello Engineer"); return 0; }

Now let me walk you through each line, one by one.



Line 1: The Comment


// This program prints "Hello Engineer" to the console

The double slash // marks a comment. The compiler completely ignores this line. Comments are written for humans — you, your teammates, or anyone who reads the code later. Think of it as a sticky note attached to your code.



Line 2: The Preprocessor Directive


#include <stdio.h>

This is called a preprocessor directive. Before your code is compiled, there is a special program called the preprocessor that runs first. Its job is to look for lines starting with # and replace them with actual content.


When it sees #include <stdio.h>, it goes and fetches the actual content of that file and inserts it into your code. The resulting expanded version is called the expanded source code.


So what is stdio.h exactly?


  • stdio stands for Standard Input Output
  • .h means it is a header file
  • This file contains the declarations (also called prototypes) of functions like printf and scanf

C code compilation Process




Why Are Declarations and Definitions Kept Separate?


This is a question many beginners miss. Here is the short answer:


  • The header file (stdio.h) holds only the declaration of functions like printf — basically a summary that tells the compiler: "Hey, this function exists and here is what it takes as input."
  • The actual code (definition) of printf lives in the C Standard Library.

There is a third program involved here called the linker. The linker's job is to map those declarations to the actual function definitions in the library. It does not copy the code — it just creates a reference link.


Why is this efficient? Because if the preprocessor had to copy the full definition of every function into your source file, the file size would explode and compilation would become painfully slow. Keeping them separate keeps compilation fast and efficient.



Line 3: The Main Function


int main() {

Every C program must have a function called main. This is the entry point — the place where execution begins. The compiler always looks for main first.


The general syntax of any function looks like this:


\[ \text{return\_type} \ \ \text{function\_name}(\text{parameters}) \{ \text{statements} \} \]


Breaking down int main():


  • int → The return type. This function will return an integer value when it finishes.
  • main → The name of the function. This is pre-defined and cannot be changed.
  • () → The parameter list. Here it is empty, which is perfectly valid.
  • { } → The curly braces enclose all the statements of the function.

You can have many functions in one program, but execution always starts from main.



Line 4: The Printf Function Call


printf("Hello Engineer");

printf is a pre-defined function written in the C standard library. You are not defining it — you are simply calling it. This is a key distinction.


  • When you define a function, you write its full body inside { }
  • When you call a function, you just write its name with the inputs inside ( ) followed by a semicolon ;

The semicolon is important — it tells the compiler that this statement is complete.



Line 5: The Return Statement


return 0;

This tells the program: "If everything ran successfully, return the integer 0 and exit." If something goes wrong inside the program, a non-zero value is returned instead. The operating system uses this value to understand whether your program ran without errors.



The Build and Run Process


Once you write the code, you need to build it and then run it.


  • Build = Tells the compiler to convert your source code into machine code. Always build first when you write new code or make changes.
  • Run = Executes the compiled machine code and shows output.

If you are running the same unchanged code again, you only need to hit Run. But if you made any modifications, always Build first, then Run.


C Programming Pipeline



Common Mistakes Beginners Make


Here are the mistakes I see most often, and they are all very easy to avoid:


  • Forgetting the semicolon after printf or return — C is strict about this. Every statement ends with ;
  • Not including the header file — If you remove #include <stdio.h>, the compiler will not know what printf is. Always include the right header for the functions you are using.
  • Changing the name of main — The entry point must be called main. You cannot rename it.
  • Confusing function definition with function call — A definition has { } with statements inside. A call just has ( ) with arguments and ends with ;
  • Making multiple changes at once when debugging — Change only one thing at a time. Otherwise you will not know which change caused which error.


Exam Tips and Quick Tricks


Here are a few things that come in handy during exams and viva:


  • Preprocessor runs before compilation — always remember: # means preprocessor, not compiler.
  • Header files store declarations; standard library stores definitions — these are two different things and the linker connects them.
  • return 0 means success — any non-zero return value signals an error.
  • Middle level language = C — this is a very commonly asked question. C is neither purely high-level nor low-level.
  • Every C program has exactly one main function — this is non-negotiable.


Quick Summary


Here is everything we covered, condensed into a clean reference:


Concept Key Idea
Procedural Language Program divided into functions
Middle Level Language Combines human-friendliness with hardware control
Preprocessor Directive Replaces #include with actual file content before compilation
Header File Stores function declarations/prototypes
Standard Library Stores actual function definitions
Linker Maps declarations to definitions without copying code
main() Mandatory entry point of every C program
return 0 Signals successful program execution


Try It Yourself


The best way to truly learn this is to get your hands on the code. Install Code::Blocks or any C IDE, type out the program above, and try these experiments one by one — not all at once:


  1. Remove the #include <stdio.h> line and see what error you get
  2. Remove the semicolon after printf
  3. Change return 0 to return 5
  4. Remove int from int main()
  5. Add a second comment line at the top

Read the error messages carefully. Understanding compiler errors is a skill in itself, and the earlier you start building that skill, the easier your journey through C programming will be.


#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Ok, Go it!