Introduction to C Programming
• • Developed by Dennis Ritchie (1972) at Bell
Labs
• • General-purpose, structured programming
language
• • Key Features:
• - Portability (runs on many systems)
• - Efficiency (low-level memory access)
• - Foundation for modern languages (C++,
Java, etc.)
Data Types and Variables
• • Basic Data Types:
• - int → integers (whole numbers)
• - float → single-precision decimal numbers
• - double → double-precision decimals
• - char → single character (e.g., 'A')
• • Declaring variables:
• int age = 20;
• float gpa = 3.5;
Control Structures
• • Decision Making:
• - if, if-else, switch
• • Loops:
• - for → fixed repetition
• - while → condition-based repetition
• - do-while → executes at least once
• Example:
• for (int i = 0; i < 5; i++) {
Functions in C
• • Purpose: Breaks program into smaller
modules
• • Syntax:
• return_type function_name(parameters) {
• // body
• }
• Example:
• int add(int a, int b) {
Arrays and Strings
• • Array: Collection of elements of the same
type
• int numbers[5] = {1,2,3,4,5};
• • String: Array of characters ending with \0
• char name[] = "Alice";
• • Arrays provide sequential storage & indexing
Pointers and Memory
Management
• • Pointer: A variable that stores memory
address
• int x = 10;
• int *ptr = &x;
• • Dereferencing: Accessing the value using
*ptr
• • Importance:
Lesson 1: Introduction to C
Language
• • History of C
• • Importance of C in system programming
• • Applications of C (Operating Systems,
Embedded Systems)
• • Structure of a C Program
Lesson 2: Input and Output in C
• • Standard I/O functions:
• - printf() for output
• - scanf() for input
• Example:
• int age;
• scanf("%d", &age);
• printf("Age: %d", age);
Lesson 3: Operators in C
• • Arithmetic Operators: +, -, *, /, %
• • Relational Operators: ==, !=, >, <, >=, <=
• • Logical Operators: &&, ||, !
• • Assignment Operators: =, +=, -=, *=, /=
• • Increment/Decrement: ++, --
Lesson 4: Structures and Unions
• • Structures: User-defined data types
• struct Student {
• int id;
• char name[20];
• };
• • Unions: Share memory for all members
• union Data {
• int i;
Lesson 5: File Handling in C
• • File operations using stdio.h
• - fopen(), fclose()
• - fprintf(), fscanf()
• - fgetc(), fputc()
• Example:
• FILE *fp = fopen("data.txt", "w");
• fprintf(fp, "Hello World");
• fclose(fp);