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%

Foundation of C & C++ — Free Notes & Tutorial

Learn C programming from scratch — variables, arrays, pointers, functions, file handling and OOP basics. Free C course at SikshaSarovar.

This Foundation of C & C++ course is part of Siksha Sarovar and is 100% free for students in India — no sign-up required to read. It contains 53 structured lessons with examples, and pairs with our free online compiler and AI tutor.

What you will learn

  • C programming
  • C++ OOP
  • Pointers
  • Arrays
  • File handling

Course content (53 lessons)

  1. Unit 1: Course Overview — Welcome to the Foundation of C & C++ This comprehensive course is designed to take you from a complete beginner to a proficient programmer in two of the most influential languages…
  2. History of C & C++: A Deep Dive — The Evolution of Systems Programming The story of C is not just about a language; it's about the birth of modern computing. It is intimately tied to the story of the UNIX…
  3. Introduction to C: Features & Philosophy — 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…
  4. Setting Up the Development Environment — Your Tools for Success To write C code, you need a workflow. While you can use a simple text editor and terminal, most professionals use an Integrated Development Environment…
  5. Variables & Fundamental Data Types — Memory and Storage A variable is a named storage location in your computer's RAM. When you declare a variable, the computer reserves a specific block of memory for it based on the…
  6. The ASCII Table: A Deep Dive — Characters are Just Small Integers In C, the char type is essentially a 1-byte integer. The mapping between the binary number in memory and the character you see on the screen is…
  7. Operators Part 1: Arithmetic & Relational — The Verbs of Your Program Operators are symbols that tell the C compiler to perform specific mathematical or logical transformations on your data (which are called "operands"). 1.…
  8. Operators Part 2: Logical & Assignments — 3. Logical Operators Used to build complex conditions by combining multiple relational expressions. Operator Name Description Example Result :--- :--- :--- :--- :--- && AND True…
  9. Output with printf: Mastering Formatting — The Art of Displaying Data The printf function (print formatted) is one of the most powerful tools in C. It doesn't just print text; it allows you to construct beautiful, aligned,…
  10. Input with scanf: Getting User Data — Making Programs Interactive A program that only prints is a lecture. A program that takes input is a conversation. scanf (scan formatted) is the primary way we get data from the…
  11. Decision Making: Logic and if-else — Controlling the Flow Most programs need to make decisions. "If the user is logged in, show their profile; otherwise, show the login page." C uses if , else , and else if for this.…
  12. The Switch Statement: Discrete Branching — Efficient Multi-Choice Logic If you are comparing a single variable against many fixed values (like a menu with options 1, 2, 3, 4), a switch statement is much cleaner and often…
  13. Looping Part 1: while and do-while — The Power of Repetition Computers are great at doing boring tasks millions of times without getting tired. Loops allow you to write a few lines of code that can run forever if…
  14. Looping Part 2: The for Loop Masterclass — The Professional's Choice The for loop is the most popular loop among C programmers because it bundles initialization, condition, and update into one concise, easy-to-read line.…
  15. Jump Statements: break, continue, and goto — Altering the Natural Flow Sometimes the standard loop conditions aren't enough. C provides three "jump" statements to override the normal behavior of loops and switches. 1. break…
  16. Arrays Part 1: Linear Collections — Storing Data in Bulk Imagine you need to store the marks of 50 students. Creating 50 variables ( mark1 , mark2 , ...) would be a nightmare. An Array allows you to store all 50…
  17. Arrays Part 2: Matrices and Grids — Two-Dimensional Arrays A 2D array is essentially an "array of arrays." It represents data in rows and columns, like a spreadsheet, a digital image, or a chess board. Declaration…
  18. String Handling: Text in C — Strings: The Hidden Reality Unlike modern languages like Java or Python, C does not have a native "String" data type. Instead, a string is simply an array of characters ending…
  19. Typedef & Enum: Expressive Code — 1. typedef (Giving Types a Nickname) The typedef keyword allows you to create an alias for an existing data type. It doesn't create a new type; it just gives a more descriptive…
  20. Functions Part 1: Modular Programming — The Strategy of Modularization A function is a self-contained block of code designed to perform one specific task. They are the primary way to organize your code into manageable,…
  21. Functions Part 2: Parameter Passing — How Data is Transferred When you pass a variable to a function, C needs to decide how to handle that memory. There are two primary techniques, each with its own specific use…
  22. Recursion: The Art of Self-Reference — A Function Calling Itself Recursion is a powerful (and sometimes mind-bending) technique where a function solves a problem by calling a smaller, simpler version of itself. It is…
  23. Storage Classes & Visibility — Lifetime and Visibility Storage classes are keywords that tell the C compiler four vital things about a variable: 1. Storage Location: Where is it in RAM? (Stack, Heap, or Data…
  24. Pointers Part 1: The Magic of Memory — The Most Powerful (and Feared) Feature A pointer is simply a special variable that stores the memory address of another variable. While they have a reputation for being difficult,…
  25. Pointers Part 2: Pointers and Arrays — The Deep Connection In C, pointers and arrays are nearly the same thing. In fact, the name of an array is actually a constant pointer that points to its very first element.…
  26. Dynamic Memory: malloc, free, and the Heap — Memory at Runtime Normal arrays ( int arr[10] ) have a fixed size that must be decided when you write the code. But what if you are building a text editor and don't know how much…
  27. Structures and Unions: Custom Types — Grouping Related Data An array lets you store 100 integers. But what if you want to store a "Student Record" which contains a name (string), an age (int), and marks (float)? You…
  28. The Preprocessor: Macros & Directives — The Silent Assistant The Preprocessor is a program that processes your source code before it ever reaches the compiler. It looks for lines starting with the hash symbol ( ). 1.…
  29. File Handling: Permanent Data Storage — Beyond the Lifespan of a Program Variables and arrays only exist in RAM. As soon as your program finishes or the power goes out, that data is gone forever. Files allow you to save…
  30. Bit Manipulation: Advanced C Programming — Thinking Like the CPU At its most fundamental level, a computer doesn't understand "10" or "Hello." It only understands high and low voltages, represented as 1 and 0 . Bit…
  31. Error Handling and Robust Coding — Writing Code that Doesn't Break In a perfect world, users always type what we expect, and memory is infinite. In the real world, things fail. A great C programmer spends 20% of…
  32. Transitioning to C++: The Next Level — Welcome to the World of C++ C++ was created in 1985 by Bjarne Stroustrup as an "upgrade" to C. While C is a Procedural language (focused on actions/functions), C++ is an…
  33. OOP Part 1: Classes and Objects — A Fundamental Shift in Thinking Object-Oriented Programming (OOP) is a style of programming where you group related data and functions into a single unit called an Object . 1. The…
  34. OOP Part 2: Constructors and Destructors — Automatic Setup and Cleanup When you create a new object, you usually want to set its starting values immediately. C++ provides a special function called a Constructor to handle…
  35. OOP Part 3: Inheritance and Code Reuse — Don't Repeat Yourself (DRY) Inheritance allows you to create a new class (the Child or Derived class) that inherits all the properties and functions of an existing class (the…
  36. OOP Part 4: Polymorphism — "One Interface, Many Forms" Polymorphism is the most advanced and magical concept in OOP. it allows you to treat different types of objects in a uniform way through a single…
  37. Exception Handling: Catching Errors — Handling the Unexpected In old-school C, if you divided by zero or ran out of memory, your program simply crashed with no explanation. C++ provides a structured way to gracefully…
  38. Introduction to the STL — C++'s Secret Weapon: The STL The Standard Template Library (STL) is a collection of pre-written, industrial-strength data structures and algorithms. Instead of spending 3 days…
  39. Special Keywords: volatile and restrict — Dealing with Hardware and Optimization C provides two advanced keywords that are essential for systems and embedded programming. They tell the compiler exactly how to optimize (or…
  40. Memory Alignment & Structure Padding — The Hidden Bytes in your Structs Have you ever checked the sizeof your structure and found that the numbers don't add up? Why does this happen? CPUs are optimized to read data…
  41. C Pitfalls and Best Practices — Avoid the Rookie Mistakes C gives you total control, but that means it also gives you many ways to fail. Here are the most common traps that even experienced developers sometimes…
  42. Classic Algorithms: Searching — The Search for Data Searching is one of the most fundamental tasks in computing. Whether you are looking for a name in a contact list or a specific record in a database, you are…
  43. Classic Algorithms: Sorting — Bringing Order to Chaos Sorting is the process of arranging data in a specific order (usually ascending or descending). It is a building block for many other algorithms (like…
  44. Data Structures: Linked Lists — Breaking the Array Limitation Arrays are great, but they have a huge flaw: their size is fixed. If you want to add an item to the middle of an array, you have to move every other…
  45. Data Structures: Stacks and Queues — Organized Data Management Stacks and Queues are "restricted" versions of linked lists or arrays. They define exactly how data enters and leaves. 1. The Stack (LIFO) Think of a…
  46. Advanced C: Multithreading Intro — Doing Two Things at Once By default, a C program is Single-Threaded . It executes one line of code at a time. In the modern world of 8-core and 16-core CPUs, this is a waste of…
  47. Advanced C: Graphics with SDL — Beyond the Text Console Are you tired of black-and-white text programs? It's time to draw! While standard C doesn't have graphics, we can use a library called SDL (Simple…
  48. Modern C++ (C++11 to C++20) — Not Your Grandpa's C++ If you look at C++ code from 1995 and C++ code from 2024, they look like different languages. Modern C++ is much safer, faster, and easier to write. Key…
  49. Career: Becoming a Systems Engineer — Your Future in Tech Learning C and C++ isn't just about syntax; it's about opening doors to some of the highest-paying and most interesting jobs in technology. Where C/C++…
  50. Advanced C: Simple XOR Encryption — The Power of Exclusive OR XOR is a bitwise operator that is its own inverse. This unique property makes it the foundation of many cryptographic algorithms. How it works If you…
  51. Advanced C: Intro to Socket Programming — Talking to the World Socket programming allows your C programs to communicate with other computers across a network (like the Internet). It is the basis for Web Servers, Chat…
  52. Modern C++: Smart Pointers in Depth — Ending the Nightmare of Memory Leaks In old C++, if you called new , you had to call delete . If you forgot, your program leaked memory. In Modern C++ (C++11 and later), we use…
  53. Congratulations and Next Steps — You Did It! You have successfully navigated the challenging waters of C and C++. You've gone from "Hello World" to complex topics like Dynamic Memory, Bit Manipulation, and…

Unit 1: Course Overview

Welcome to the Foundation of C & C++

This comprehensive course is designed to take you from a complete beginner to a proficient programmer in two of the most influential languages in computer science: C and C++.

Why Learn C and C++?

C is often called the "Mother of all languages." It was developed at Bell Labs by Dennis Ritchie and has been the foundation for operating systems like UNIX, Windows, and Linux. C++ was later developed by Bjarne Stroustrup as an extension of C, adding Object-Oriented Programming (OOP) features.

Key Benefits:

  1. Performance: These languages are incredibly fast and efficient. Most performance-critical software like games, browsers, and OS kernels are written in C/C++. Unlike languages with virtual machines (like Java or Python), C and C++ compile directly to machine code, removing any "middleman" between your logic and the CPU.
  2. Control: You get direct access to system memory and hardware. This is essential for systems programming, driver development, and embedded devices where every byte and microsecond counts. In C, you are in charge of the memory; you decide when it is allocated and when it is freed.
  3. Versatility: Used in everything from the smallest microcontrollers in your microwave to the world's most powerful supercomputers used for weather prediction. If it runs on electricity and requires logic, there's a good chance some C or C++ is involved in its operation.
  4. Foundation: Understanding C makes learning any other language much easier. Because you understand concepts like pointers and memory addresses, abstractions in languages like Java, Python, or JavaScript will no longer seem like "magic" to you.

What You Will Learn

  • Fundamental Syntax: Master the basic building blocks of any program: variables, data types, and operators.
  • Logic Building: Develop deep algorithmic thinking through loops and conditional statements.
  • Memory Management: Dive deep into the computer's RAM. Learn about pointers, addresses, and manual memory management using the Heap and Stack. This is the part of the course that truly separates the professionals from the amateurs.
  • Data Structures: Build custom, complex data types using structures, unions, and enums to represent real-world data effectively.
  • Object-Oriented Programming (C++): Learn to model real-world problems using classes, objects, inheritance, and polymorphism, enabling you to manage massive codebases.
  • File Systems: Learn how to read from and write to permanent storage, allowing your programs to save data (like game progress or database records) beyond their execution lifetime.

Visual Learning Path

The flowchart above illustrates the progression of this course. We start with the core procedural concepts of C—the foundation of modern computing—and gradually transition into the powerful abstraction layers of C++, enabling you to build large-scale, maintainable software systems.

Recommended Resources

  • Compiler: We recommend using GCC (GNU Compiler Collection) or Clang. These are industry-standard, cross-platform, and free.
  • IDE: Visual Studio Code with the C/C++ extension by Microsoft is the gold standard for modern, lightweight development.
  • Practice: Code every day! Programming is a skill learned through persistent practice. Solve problems on platforms like LeetCode, HackerRank, or Project Euler to sharpen your skills.

Course Philosophy

We believe in "Learning by Doing." Each lesson includes code snippets that you should type out and run yourself. Don't just copy-paste! The physical act of typing the code helps with "muscle memory" for syntax. Experiment with the values, intentionally break the code to see the errors, and then fix it. That's how real learning happens.

Don't get discouraged by pointers! They are the most powerful part of C, and once they "click," you'll have a superpower in programming. Every great programmer was once where you are now. Keep pushing forward!

History of C & C++: A Deep Dive

The Evolution of Systems Programming

The story of C is not just about a language; it's about the birth of modern computing. It is intimately tied to the story of the UNIX operating system. In the late 1960s, researchers at AT&T Bell Labs were working on a massive operating system called Multics. When Multics was cancelled, Ken Thompson and Dennis Ritchie needed a new environment to continue their work.

Timeline of Innovation

  1. 1969: Ken Thompson creates the B language, a stripped-down version of BCPL (Basic Combined Programming Language). B was "untyped"—everything was treated as a single "word" of data.
  2. 1970: Thompson and Ritchie use B to write the first version of UNIX for the PDP-7, a computer with very limited memory.
  3. 1972: Dennis Ritchie evolves B into C. He adds "types" (int, char, float) and the ability to describe complex data structures. This allowed C to describe hardware more accurately while remaining readable.
  4. 1973: The UNIX kernel is rewritten in C. This was a revolutionary moment. Previously, OS kernels were written in Assembly language, which was tied to specific hardware. Rewriting UNIX in C made the operating system "portable"—it could run on any machine that had a C compiler.
  5. 1978: Brian Kernighan and Dennis Ritchie publish the first edition of "The C Programming Language" (K&R C). This book became the "bible" for programmers and the unofficial standard for the language for over a decade.
  6. 1983: Bjarne Stroustrup starts work on "C with Classes" at Bell Labs. He wanted to combine the efficiency of C with the organizational power of Simula (an early OOP language).
  7. 1985: "C with Classes" is renamed to C++ and released. The name was suggested by Rick Mascitti; the "++" is the increment operator in C, symbolizing that C++ is the "next step" or "increment" of C.
  8. 1989: ANSI C is standardized (C89), providing a formal, rigorous definition of the language to ensure code worked the same way on every compiler.
  9. 1999: C99 standard is released, adding modern features like inline functions, variable-length arrays, and long long integers.
  10. 2011: C++11 is released, often called "Modern C++." It brought massive changes like the auto keyword, lambda expressions, smart pointers, and a standardized multi-threading library.

The Impact of C

C's syntax and logic have influenced almost every language created since. Java, C#, PHP, JavaScript, Perl, and Objective-C all borrowed heavily from C. When you learn C, you aren't just learning one language; you are learning the "DNA" of the software industry.

Fun Fact: The Bootstrapping Process

How do you write a compiler for a new language? You have to write it in an existing language. The first C compiler was written in B. But once the C compiler was functional enough, the developers used C to write a better version of the C compiler. This is called bootstrapping.

The Philosophy of Performance

Both C and C++ are built on the "Zero-Overhead Principle." This means:

  • You don't pay (in performance) for what you don't use.
  • The features you do use are as efficient as if you had written them manually in Assembly.
Despite being decades old, C and C++ consistently rank in the top 5 of the TIOBE index, showing their enduring relevance in the tech world. From the software in your car's engine to the servers running the internet, C and C++ are everywhere.

Frequently asked questions

Is the Foundation of C & C++ course really free?

Yes. The entire Foundation of C & C++ course on Siksha Sarovar is free to read with no account required. You can optionally sign in with Google to save your progress.

Do I get a certificate for Foundation of C & C++?

Yes — finish the lessons and pass the quiz to earn a free, verifiable certificate you can share on LinkedIn or with recruiters.

Can I run code while learning?

Yes. The built-in online compiler runs C, C++, Python, Java, PHP, JavaScript, C# and SQL directly in your browser — no installation needed.