C Programming Workshop Complete
C Programming Workshop Complete
Workshop
Comprehensive Guide with Examples
and Animations
Setting Up the C Environment -
Part 1
• • Install GCC Compiler
• • Recommended IDEs: CodeBlocks, Dev-C++,
Turbo C++
• • Running a simple C program
Structure of a C Program - Part 1
• #include <stdio.h>
• int main() {
• printf("Hello, World!\n");
• return 0;
• }
Variables and Data Types - Part 1
• • int, float, char, double
• • Example:
• int age = 25;
• float height = 5.9;
• char grade = 'A';
Operators in C - Part 1
• • Arithmetic: +, -, *, /, %
• • Relational: ==, !=, >, <, >=, <=
• • Logical: &&, ||, !
• • Assignment: =, +=, -=, *=, /=
• • Bitwise: &, |, ^, ~, <<, >>
Control Statements - Part 1
• • Conditional: if, if-else, switch-case
• • Loops: for, while, do-while
• • Example:
• for(int i = 0; i < 5; i++) {
• printf("Iteration %d\n", i);
• }
Functions in C - Part 1
• • Function declaration, definition, and calling
• • Example:
• int add(int a, int b) {
• return a + b;
• }
• int main() {
• int sum = add(5, 10);
• printf("Sum: %d", sum);
• return 0;
Arrays in C - Part 1
• • int arr[5] = {1, 2, 3, 4, 5};
• • Traversing arrays using loops
Pointers in C - Part 1
• • int *ptr;
• • Pointer arithmetic
• • Example:
• int a = 10;
• int *ptr = &a;
• printf("Value of a: %d", *ptr);
Structures and Unions - Part 1
• • struct Student { char name[50]; int age; float
marks; };
• • union Data { int i; float f; };
File Handling - Part 1
• • File operations: fopen(), fclose(), fprintf(),
fscanf()
• • Example:
• FILE *fptr;
• fptr = fopen("file.txt", "w");
• fprintf(fptr, "Hello, File!");
• fclose(fptr);
Memory Management - Part 1
• • malloc(), calloc(), realloc(), free()
• • Example:
• int *ptr;
• ptr = (int*) malloc(5 * sizeof(int));
• free(ptr);
Common Errors and Debugging -
Part 1
• • Syntax, logical, and runtime errors
• • Debugging techniques using gdb
Quiz and Q&A - Part 1
• • Short quiz with multiple-choice questions
• • Open Q&A session
Introduction to C - Part 2
• • Developed by Dennis Ritchie in 1972
• • Portable and fast
• • Used in system programming and embedded
systems
Setting Up the C Environment -
Part 2
• • Install GCC Compiler
• • Recommended IDEs: CodeBlocks, Dev-C++,
Turbo C++
• • Running a simple C program
Structure of a C Program - Part 2
• #include <stdio.h>
• int main() {
• printf("Hello, World!\n");
• return 0;
• }
Variables and Data Types - Part 2
• • int, float, char, double
• • Example:
• int age = 25;
• float height = 5.9;
• char grade = 'A';
Operators in C - Part 2
• • Arithmetic: +, -, *, /, %
• • Relational: ==, !=, >, <, >=, <=
• • Logical: &&, ||, !
• • Assignment: =, +=, -=, *=, /=
• • Bitwise: &, |, ^, ~, <<, >>
Control Statements - Part 2
• • Conditional: if, if-else, switch-case
• • Loops: for, while, do-while
• • Example:
• for(int i = 0; i < 5; i++) {
• printf("Iteration %d\n", i);
• }
Functions in C - Part 2
• • Function declaration, definition, and calling
• • Example:
• int add(int a, int b) {
• return a + b;
• }
• int main() {
• int sum = add(5, 10);
• printf("Sum: %d", sum);
• return 0;
Arrays in C - Part 2
• • int arr[5] = {1, 2, 3, 4, 5};
• • Traversing arrays using loops
Pointers in C - Part 2
• • int *ptr;
• • Pointer arithmetic
• • Example:
• int a = 10;
• int *ptr = &a;
• printf("Value of a: %d", *ptr);
Structures and Unions - Part 2
• • struct Student { char name[50]; int age; float
marks; };
• • union Data { int i; float f; };
File Handling - Part 2
• • File operations: fopen(), fclose(), fprintf(),
fscanf()
• • Example:
• FILE *fptr;
• fptr = fopen("file.txt", "w");
• fprintf(fptr, "Hello, File!");
• fclose(fptr);
Memory Management - Part 2
• • malloc(), calloc(), realloc(), free()
• • Example:
• int *ptr;
• ptr = (int*) malloc(5 * sizeof(int));
• free(ptr);
Common Errors and Debugging -
Part 2
• • Syntax, logical, and runtime errors
• • Debugging techniques using gdb
Quiz and Q&A - Part 2
• • Short quiz with multiple-choice questions
• • Open Q&A session
Introduction to C - Part 3
• • Developed by Dennis Ritchie in 1972
• • Portable and fast
• • Used in system programming and embedded
systems
Setting Up the C Environment -
Part 3
• • Install GCC Compiler
• • Recommended IDEs: CodeBlocks, Dev-C++,
Turbo C++
• • Running a simple C program
Structure of a C Program - Part 3
• #include <stdio.h>
• int main() {
• printf("Hello, World!\n");
• return 0;
• }
Variables and Data Types - Part 3
• • int, float, char, double
• • Example:
• int age = 25;
• float height = 5.9;
• char grade = 'A';
Operators in C - Part 3
• • Arithmetic: +, -, *, /, %
• • Relational: ==, !=, >, <, >=, <=
• • Logical: &&, ||, !
• • Assignment: =, +=, -=, *=, /=
• • Bitwise: &, |, ^, ~, <<, >>
Control Statements - Part 3
• • Conditional: if, if-else, switch-case
• • Loops: for, while, do-while
• • Example:
• for(int i = 0; i < 5; i++) {
• printf("Iteration %d\n", i);
• }
Functions in C - Part 3
• • Function declaration, definition, and calling
• • Example:
• int add(int a, int b) {
• return a + b;
• }
• int main() {
• int sum = add(5, 10);
• printf("Sum: %d", sum);
• return 0;
Arrays in C - Part 3
• • int arr[5] = {1, 2, 3, 4, 5};
• • Traversing arrays using loops
Pointers in C - Part 3
• • int *ptr;
• • Pointer arithmetic
• • Example:
• int a = 10;
• int *ptr = &a;
• printf("Value of a: %d", *ptr);
Structures and Unions - Part 3
• • struct Student { char name[50]; int age; float
marks; };
• • union Data { int i; float f; };
File Handling - Part 3
• • File operations: fopen(), fclose(), fprintf(),
fscanf()
• • Example:
• FILE *fptr;
• fptr = fopen("file.txt", "w");
• fprintf(fptr, "Hello, File!");
• fclose(fptr);
Memory Management - Part 3
• • malloc(), calloc(), realloc(), free()
• • Example:
• int *ptr;
• ptr = (int*) malloc(5 * sizeof(int));
• free(ptr);
Common Errors and Debugging -
Part 3
• • Syntax, logical, and runtime errors
• • Debugging techniques using gdb
Quiz and Q&A - Part 3
• • Short quiz with multiple-choice questions
• • Open Q&A session
Introduction to C - Part 4
• • Developed by Dennis Ritchie in 1972
• • Portable and fast
• • Used in system programming and embedded
systems
Setting Up the C Environment -
Part 4
• • Install GCC Compiler
• • Recommended IDEs: CodeBlocks, Dev-C++,
Turbo C++
• • Running a simple C program
Structure of a C Program - Part 4
• #include <stdio.h>
• int main() {
• printf("Hello, World!\n");
• return 0;
• }
Variables and Data Types - Part 4
• • int, float, char, double
• • Example:
• int age = 25;
• float height = 5.9;
• char grade = 'A';
Operators in C - Part 4
• • Arithmetic: +, -, *, /, %
• • Relational: ==, !=, >, <, >=, <=
• • Logical: &&, ||, !
• • Assignment: =, +=, -=, *=, /=
• • Bitwise: &, |, ^, ~, <<, >>
Control Statements - Part 4
• • Conditional: if, if-else, switch-case
• • Loops: for, while, do-while
• • Example:
• for(int i = 0; i < 5; i++) {
• printf("Iteration %d\n", i);
• }
Functions in C - Part 4
• • Function declaration, definition, and calling
• • Example:
• int add(int a, int b) {
• return a + b;
• }
• int main() {
• int sum = add(5, 10);
• printf("Sum: %d", sum);
• return 0;
Arrays in C - Part 4
• • int arr[5] = {1, 2, 3, 4, 5};
• • Traversing arrays using loops
Pointers in C - Part 4
• • int *ptr;
• • Pointer arithmetic
• • Example:
• int a = 10;
• int *ptr = &a;
• printf("Value of a: %d", *ptr);
Structures and Unions - Part 4
• • struct Student { char name[50]; int age; float
marks; };
• • union Data { int i; float f; };
File Handling - Part 4
• • File operations: fopen(), fclose(), fprintf(),
fscanf()
• • Example:
• FILE *fptr;
• fptr = fopen("file.txt", "w");
• fprintf(fptr, "Hello, File!");
• fclose(fptr);
Memory Management - Part 4
• • malloc(), calloc(), realloc(), free()
• • Example:
• int *ptr;
• ptr = (int*) malloc(5 * sizeof(int));
• free(ptr);
Common Errors and Debugging -
Part 4
• • Syntax, logical, and runtime errors
• • Debugging techniques using gdb
Quiz and Q&A - Part 4
• • Short quiz with multiple-choice questions
• • Open Q&A session
Introduction to C - Part 5
• • Developed by Dennis Ritchie in 1972
• • Portable and fast
• • Used in system programming and embedded
systems
Setting Up the C Environment -
Part 5
• • Install GCC Compiler
• • Recommended IDEs: CodeBlocks, Dev-C++,
Turbo C++
• • Running a simple C program
Structure of a C Program - Part 5
• #include <stdio.h>
• int main() {
• printf("Hello, World!\n");
• return 0;
• }
Variables and Data Types - Part 5
• • int, float, char, double
• • Example:
• int age = 25;
• float height = 5.9;
• char grade = 'A';
Operators in C - Part 5
• • Arithmetic: +, -, *, /, %
• • Relational: ==, !=, >, <, >=, <=
• • Logical: &&, ||, !
• • Assignment: =, +=, -=, *=, /=
• • Bitwise: &, |, ^, ~, <<, >>
Control Statements - Part 5
• • Conditional: if, if-else, switch-case
• • Loops: for, while, do-while
• • Example:
• for(int i = 0; i < 5; i++) {
• printf("Iteration %d\n", i);
• }
Functions in C - Part 5
• • Function declaration, definition, and calling
• • Example:
• int add(int a, int b) {
• return a + b;
• }
• int main() {
• int sum = add(5, 10);
• printf("Sum: %d", sum);
• return 0;
Arrays in C - Part 5
• • int arr[5] = {1, 2, 3, 4, 5};
• • Traversing arrays using loops
Pointers in C - Part 5
• • int *ptr;
• • Pointer arithmetic
• • Example:
• int a = 10;
• int *ptr = &a;
• printf("Value of a: %d", *ptr);
Structures and Unions - Part 5
• • struct Student { char name[50]; int age; float
marks; };
• • union Data { int i; float f; };
File Handling - Part 5
• • File operations: fopen(), fclose(), fprintf(),
fscanf()
• • Example:
• FILE *fptr;
• fptr = fopen("file.txt", "w");
• fprintf(fptr, "Hello, File!");
• fclose(fptr);
Memory Management - Part 5
• • malloc(), calloc(), realloc(), free()
• • Example:
• int *ptr;
• ptr = (int*) malloc(5 * sizeof(int));
• free(ptr);
Common Errors and Debugging -
Part 5
• • Syntax, logical, and runtime errors
• • Debugging techniques using gdb
Quiz and Q&A - Part 5
• • Short quiz with multiple-choice questions
• • Open Q&A session
Introduction to C - Part 6
• • Developed by Dennis Ritchie in 1972
• • Portable and fast
• • Used in system programming and embedded
systems
Setting Up the C Environment -
Part 6
• • Install GCC Compiler
• • Recommended IDEs: CodeBlocks, Dev-C++,
Turbo C++
• • Running a simple C program
Structure of a C Program - Part 6
• #include <stdio.h>
• int main() {
• printf("Hello, World!\n");
• return 0;
• }
Variables and Data Types - Part 6
• • int, float, char, double
• • Example:
• int age = 25;
• float height = 5.9;
• char grade = 'A';
Operators in C - Part 6
• • Arithmetic: +, -, *, /, %
• • Relational: ==, !=, >, <, >=, <=
• • Logical: &&, ||, !
• • Assignment: =, +=, -=, *=, /=
• • Bitwise: &, |, ^, ~, <<, >>
Control Statements - Part 6
• • Conditional: if, if-else, switch-case
• • Loops: for, while, do-while
• • Example:
• for(int i = 0; i < 5; i++) {
• printf("Iteration %d\n", i);
• }
Functions in C - Part 6
• • Function declaration, definition, and calling
• • Example:
• int add(int a, int b) {
• return a + b;
• }
• int main() {
• int sum = add(5, 10);
• printf("Sum: %d", sum);
• return 0;
Arrays in C - Part 6
• • int arr[5] = {1, 2, 3, 4, 5};
• • Traversing arrays using loops
Pointers in C - Part 6
• • int *ptr;
• • Pointer arithmetic
• • Example:
• int a = 10;
• int *ptr = &a;
• printf("Value of a: %d", *ptr);
Structures and Unions - Part 6
• • struct Student { char name[50]; int age; float
marks; };
• • union Data { int i; float f; };
File Handling - Part 6
• • File operations: fopen(), fclose(), fprintf(),
fscanf()
• • Example:
• FILE *fptr;
• fptr = fopen("file.txt", "w");
• fprintf(fptr, "Hello, File!");
• fclose(fptr);
Memory Management - Part 6
• • malloc(), calloc(), realloc(), free()
• • Example:
• int *ptr;
• ptr = (int*) malloc(5 * sizeof(int));
• free(ptr);
Common Errors and Debugging -
Part 6
• • Syntax, logical, and runtime errors
• • Debugging techniques using gdb
Quiz and Q&A - Part 6
• • Short quiz with multiple-choice questions
• • Open Q&A session
Introduction to C - Part 7
• • Developed by Dennis Ritchie in 1972
• • Portable and fast
• • Used in system programming and embedded
systems
Setting Up the C Environment -
Part 7
• • Install GCC Compiler
• • Recommended IDEs: CodeBlocks, Dev-C++,
Turbo C++
• • Running a simple C program
Structure of a C Program - Part 7
• #include <stdio.h>
• int main() {
• printf("Hello, World!\n");
• return 0;
• }
Variables and Data Types - Part 7
• • int, float, char, double
• • Example:
• int age = 25;
• float height = 5.9;
• char grade = 'A';
Operators in C - Part 7
• • Arithmetic: +, -, *, /, %
• • Relational: ==, !=, >, <, >=, <=
• • Logical: &&, ||, !
• • Assignment: =, +=, -=, *=, /=
• • Bitwise: &, |, ^, ~, <<, >>
Control Statements - Part 7
• • Conditional: if, if-else, switch-case
• • Loops: for, while, do-while
• • Example:
• for(int i = 0; i < 5; i++) {
• printf("Iteration %d\n", i);
• }
Functions in C - Part 7
• • Function declaration, definition, and calling
• • Example:
• int add(int a, int b) {
• return a + b;
• }
• int main() {
• int sum = add(5, 10);
• printf("Sum: %d", sum);
• return 0;
Arrays in C - Part 7
• • int arr[5] = {1, 2, 3, 4, 5};
• • Traversing arrays using loops
Pointers in C - Part 7
• • int *ptr;
• • Pointer arithmetic
• • Example:
• int a = 10;
• int *ptr = &a;
• printf("Value of a: %d", *ptr);
Structures and Unions - Part 7
• • struct Student { char name[50]; int age; float
marks; };
• • union Data { int i; float f; };
File Handling - Part 7
• • File operations: fopen(), fclose(), fprintf(),
fscanf()
• • Example:
• FILE *fptr;
• fptr = fopen("file.txt", "w");
• fprintf(fptr, "Hello, File!");
• fclose(fptr);
Memory Management - Part 7
• • malloc(), calloc(), realloc(), free()
• • Example:
• int *ptr;
• ptr = (int*) malloc(5 * sizeof(int));
• free(ptr);
Common Errors and Debugging -
Part 7
• • Syntax, logical, and runtime errors
• • Debugging techniques using gdb
Quiz and Q&A - Part 7
• • Short quiz with multiple-choice questions
• • Open Q&A session
Introduction to C - Part 8
• • Developed by Dennis Ritchie in 1972
• • Portable and fast
• • Used in system programming and embedded
systems
Setting Up the C Environment -
Part 8
• • Install GCC Compiler
• • Recommended IDEs: CodeBlocks, Dev-C++,
Turbo C++
• • Running a simple C program
Structure of a C Program - Part 8
• #include <stdio.h>
• int main() {
• printf("Hello, World!\n");
• return 0;
• }