Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Introduction to C: Features & Philosophy

Lesson 3 of 53 in the free Foundation of C & C++ notes on Siksha Sarovar, written by Rohit Jangra.

Core Features of C

  1. Procedural Language: Programs are organized as a sequence of instructions or function calls. It follows a top-down approach where you define exactly the steps the computer should take to solve a problem.
  2. Middle-Level Language: It occupies a "sweet spot" in computer science. It combines the power of low-level languages (like direct memory access and bit manipulation) with the readability and abstraction of high-level languages.
  3. Fast and Efficient: Direct interaction with memory and minimal runtime overhead make C execution lightning-fast. There is no "garbage collector" or "virtual machine" slowing things down.
  4. Rich Library: C comes with a vast set of built-in functions in standard libraries (<stdio.h>, <math.h>, <string.h>, <stdlib.h>, etc.).
  5. Extensibility: You can easily add your own functions to the C library or create your own header files to reuse code across projects.
  6. Recursion: C supports recursion, allowing a function to call itself, which is a powerful tool for mathematical calculations and tree-based data structures.
  7. Static Typing: Data types are checked at compile-time, which catches many errors before the program even runs.

The Philosophy of C

The guiding principle of C is "Trust the Programmer." C does not have "training wheels."

  • It won't stop you from writing past the end of an array.
  • It won't stop you from accessing a memory address that doesn't belong to you.
  • It won't automatically clean up memory you've allocated.

This gives you ultimate power and efficiency, but it requires ultimate responsibility. A C programmer is like a professional race car driver—you have total control, but if you make a mistake at high speed, the consequences are immediate.

Anatomy of a C Program

Let's look closer at our first program:

#include <stdio.h> // Preprocessor directive

// The entry point of every C program
int main() {         
  // Your code here
  printf("Hello, Siksha Sarovar!\n"); 
  
  // Exit status returned to OS (0 usually means success)
  return 0;          
}

Detailed Breakdown:

  • #include <stdio.h>: Tells the preprocessor to copy the contents of the Standard Input Output header into this file. This provides the "blueprint" for functions like printf.
  • int main(): The main entry point. The Operating System calls this function when the program starts. The int indicates that it will return an integer value to the OS upon completion.
  • printf(...): "print formatted". It sends text to the standard output (usually the console). The \n is an escape sequence that moves the cursor to a new line.
  • return 0;: A convention where 0 means "Everything is OK." Non-zero values usually indicate an error code.

Keywords in C

C has a small, elegant set of reserved keywords. You cannot use these as variable names because they have special meaning to the compiler.

Full List (C89 standard): auto, break, case, char, const, continue, default, do, double, else, enum, extern, float, for, goto, if, int, long, register, return, short, signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile, while.

Identifiers

Identifiers are names you give to variables, functions, and arrays.

  • Must start with a letter (a-z, A-Z) or an underscore (_).
  • Can contain digits (0-9) but not at the start.
  • No special characters (like !, @, #) except underscore.
  • No keywords allowed.
  • Maximum length is typically 31 characters (depending on the compiler).
C is case-sensitive. main, Main, and MAIN are three completely different names to the compiler. Always use lowercase for keywords and standard function names!