📘Mastering C Programming : Complete Course
Complete Course: Mastering C Programming
🔹Module 1: Introduction to C Language
1.1 What is C?
-
Created by Dennis Ritchie (1972) at Bell Labs.
-
Used to develop UNIX, still popular today for operating systems, compilers, drivers, embedded systems.
-
Powerful, low-level, but portable.
1.2 Environment Setup
-
Install GCC (Linux/Mac) or MinGW (Windows).
-
Recommended IDEs: Code::Blocks, Dev-C++, or VSCode with C/C++ extension.
1.3 First Program: Hello World
#include
int main() {
printf("Hello, World!\n");
return 0;
}
-
#include→ include standard input/output library. -
int main()→ program entry point. -
printf()→ displays output. -
return 0;→ ends program successfully.
Exercise 1: Write a program that prints your name, age, and city.
🔹 Module 2: Basics of the Language
2.1 Data Types
-
int: integers (4 bytes)
-
float: decimals (4 bytes)
-
double: double precision decimals (8 bytes)
-
char: characters (1 byte)
-
void: no value
2.2 Variables and Constants
int age = 20;
const float PI = 3.1416;
char initial = 'A';
2.3 Operators
-
Arithmetic:
+ - * / % -
Relational:
== != > < >= <= -
Logical:
&& || !
Exercise 2: Create a program that calculates the area of a circle (PI * r * r).
🔹 Module 3: Control Structures
3.1 Conditions
if (age >= 18) {
printf("Adult\n");
} else {
printf("Minor\n");
}
3.2 Switch
switch (grade) {
case 20: printf("Excellent\n"); break;
case 10: printf("Average\n"); break;
default: printf("Other\n"); break;
}
3.3 Loops
for (int i = 0; i < 10; i++) printf("%d\n", i);
while (x > 0) { printf("%d", x); x--; }
Exercise 3: Display the multiplication table of a number entered by the user.
🔹 Module 4: Functions
4.1 Defining a Function
int square(int n) {
return n * n;
}
4.2 Passing by Value and by Pointer
void increment(int *x) {
(*x)++;
}
Exercise 4: Write a function that finds the maximum of two numbers.
🔹 Module 5: Arrays and Strings
5.1 Arrays
int scores[5] = {10, 12, 15, 18, 20};
5.2 Strings
char name[20] = "Alice";
printf("Hello %s", name);
5.3 Useful String Functions ()
-
strlen(),strcpy(),strcmp(),strcat().
Exercise 5: Write a program that reads a word and counts its letters.
🔹 Module 6: Pointers
6.1 Introduction
int x = 5;
int *p = &x;
printf("%d", *p); // prints 5
6.2 Dynamic Memory Allocation
int *arr = (int*)malloc(5 * sizeof(int));
free(arr);
Exercise 6: Create a dynamic array that stores N numbers and calculates their average.
🔹 Module 7: Structures and Files
7.1 Structures
struct Student {
char name[30];
int age;
float gpa;
};
7.2 Files
FILE *f = fopen("data.txt", "w");
fprintf(f, "Hello");
fclose(f);
Exercise 7: Write a program that stores a list of students in a text file.
🔹 Module 8: Advanced Concepts
-
Function pointers
-
Linked lists
-
Error handling with
errno -
Preprocessor (
#define,#ifdef)
🔹 Module 9: Final Project
Build a complete console application.
Example: Mini Banking System
-
Add / delete a client
-
Deposit and withdraw money
-
Save data into a text file
Expected Outcomes
By the end of this training, you will be able to:
✔️ Write correct and efficient C programs
✔️ Manage memory with pointers and dynamic allocation
✔️ Handle files and complex data structures
✔️ Build real-world system applications