C Programming — Complete Notes (Compiled)
All C Programming semester lecture notes compiled systematically in official syllabus sequence.
10 sectionsLast updated 2026-10-11
This compiled collection contains the full subject overview followed by every single unit note in chapter order.
C Programming — Complete Course Notes (BCA 1st Sem)
Welcome to the comprehensive lecture and study notes for C Programming (Course Code: CACS101), strictly adhering to the Tribhuvan University (TU) BCA 1st Semester syllabus.
1. Fundamentals of C Programming
C is a general-purpose, procedural, middle-level programming language developed in 1972 by Dennis M. Ritchie at Bell Telephone Laboratories to develop the UNIX operating system.
Key Characteristics:
- Middle-Level Language: Combines the high-level readability of user-defined functions and structures with low-level direct memory manipulation using pointers.
- Structured Programming: Modular design using functions, loops, and block-scoped variables.
- Portability & Efficiency: Generates compact, highly optimized native machine assembly code.
```c #include <stdio.h>
int main(void) { printf("Hello, EduNepal Student!\n"); return 0; } ```
2. Compilation and Execution Process
The transition from human-readable C source code (.c) to an executable binary (.exe or ELF) consists of four sequential phases:
- Preprocessing (
cpp): Expands macros (#define), strips comments, and includes header files (#include). - Compilation (
cc1): Converts preprocessed code into assembly instructions. - Assembly (
as): Translates assembly code into relocatable object code (.oor.obj). - Linking (
ld): Combines object files with C standard libraries (libc) to produce the final executable.
3. Data Types and Memory Footprint (32/64-bit Architecture)
| Data Type | Keyword | Size (Bytes) | Format Specifier | Typical Range |
|---|---|---|---|---|
| Character | char | 1 | %c | -128 to 127 |
| Integer | int | 4 | %d | -2,147,483,648 to 2,147,483,647 |
| Floating Point | float | 4 | %f | 1.2E-38 to 3.4E+38 (6 decimals) |
| Double Precision | double | 8 | %lf | 2.3E-308 to 1.7E+308 (15 decimals) |
| Void | void | 0 | - | Valueless |
4. Control Statements & Decision Making
If-Else Decision Making:
```c #include <stdio.h>
int main() { int score; printf("Enter exam marks (0-100): "); scanf("%d", &score);
if (score >= 80) { printf("Grade: Distinction\n"); } else if (score >= 60) { printf("Grade: First Division\n"); } else if (score >= 40) { printf("Grade: Pass\n"); } else { printf("Grade: Fail\n"); } return 0; } ```
5. Pointers and Dynamic Memory Allocation
A pointer is a variable that stores the memory address of another variable.
- The address-of operator
&retrieves the memory address. - The dereference operator
*accesses the value stored at that address.
```c #include <stdio.h> #include <stdlib.h>
int main() { int ptr = (int )malloc(5 * sizeof(int)); if (ptr == NULL) { printf("Memory allocation failed!\n"); return 1; }
for (int i = 0; i < 5; i++) { ptr[i] = (i + 1) 10; printf("Element %d at %p = %d\n", i, (void)&ptr[i], ptr[i]); }
free(ptr); // Prevent memory leak return 0; } ```
Unit 1: Introduction to Programming Concepts and C Language Notes
Course: C Programming (CACS101) | Term: BCA 1st Semester | Teaching Hours: 6.0 Hours
Unit Overview
This unit focuses on Introduction to Programming Concepts and C Language, exploring key syntax, structural paradigms, common pitfalls, and practical code implementations.
Essential Concepts:
- Theoretical Foundations: Core definitions, historical rationale, and design architecture.
- Syntax & Examples: Compilable ANSI C code snippets demonstrating real-world usage.
- Common University Questions: Frequently tested questions in TU FOHSS board examinations.
```c /* Practical demonstration for Introduction to Programming Concepts and C Language */ #include <stdio.h>
void demonstrateConcept(void) { printf("Demonstrating key concepts of: %s ", "Introduction to Programming Concepts and C Language"); }
int main(void) { demonstrateConcept(); return 0; } ```
Self-Assessment & Review Questions:
- Define the primary mechanics of Introduction to Programming Concepts and C Language.
- Differentiate between the fundamental paradigms introduced in this chapter.
- Write a short, self-contained C routine illustrating best practices for memory and CPU efficiency.
Unit 2: Operators and Expressions Notes
Course: C Programming (CACS101) | Term: BCA 1st Semester | Teaching Hours: 7.0 Hours
Unit Overview
This unit focuses on Operators and Expressions, exploring key syntax, structural paradigms, common pitfalls, and practical code implementations.
Essential Concepts:
- Theoretical Foundations: Core definitions, historical rationale, and design architecture.
- Syntax & Examples: Compilable ANSI C code snippets demonstrating real-world usage.
- Common University Questions: Frequently tested questions in TU FOHSS board examinations.
```c /* Practical demonstration for Operators and Expressions */ #include <stdio.h>
void demonstrateConcept(void) { printf("Demonstrating key concepts of: %s ", "Operators and Expressions"); }
int main(void) { demonstrateConcept(); return 0; } ```
Self-Assessment & Review Questions:
- Define the primary mechanics of Operators and Expressions.
- Differentiate between the fundamental paradigms introduced in this chapter.
- Write a short, self-contained C routine illustrating best practices for memory and CPU efficiency.
Unit 3: Input and Output Operations Notes
Course: C Programming (CACS101) | Term: BCA 1st Semester | Teaching Hours: 4.0 Hours
Unit Overview
This unit focuses on Input and Output Operations, exploring key syntax, structural paradigms, common pitfalls, and practical code implementations.
Essential Concepts:
- Theoretical Foundations: Core definitions, historical rationale, and design architecture.
- Syntax & Examples: Compilable ANSI C code snippets demonstrating real-world usage.
- Common University Questions: Frequently tested questions in TU FOHSS board examinations.
```c /* Practical demonstration for Input and Output Operations */ #include <stdio.h>
void demonstrateConcept(void) { printf("Demonstrating key concepts of: %s ", "Input and Output Operations"); }
int main(void) { demonstrateConcept(); return 0; } ```
Self-Assessment & Review Questions:
- Define the primary mechanics of Input and Output Operations.
- Differentiate between the fundamental paradigms introduced in this chapter.
- Write a short, self-contained C routine illustrating best practices for memory and CPU efficiency.
Unit 4: Control Statements and Decision Making Notes
Course: C Programming (CACS101) | Term: BCA 1st Semester | Teaching Hours: 8.0 Hours
Unit Overview
This unit focuses on Control Statements and Decision Making, exploring key syntax, structural paradigms, common pitfalls, and practical code implementations.
Essential Concepts:
- Theoretical Foundations: Core definitions, historical rationale, and design architecture.
- Syntax & Examples: Compilable ANSI C code snippets demonstrating real-world usage.
- Common University Questions: Frequently tested questions in TU FOHSS board examinations.
```c /* Practical demonstration for Control Statements and Decision Making */ #include <stdio.h>
void demonstrateConcept(void) { printf("Demonstrating key concepts of: %s ", "Control Statements and Decision Making"); }
int main(void) { demonstrateConcept(); return 0; } ```
Self-Assessment & Review Questions:
- Define the primary mechanics of Control Statements and Decision Making.
- Differentiate between the fundamental paradigms introduced in this chapter.
- Write a short, self-contained C routine illustrating best practices for memory and CPU efficiency.
Unit 5: Arrays and String Manipulations Notes
Course: C Programming (CACS101) | Term: BCA 1st Semester | Teaching Hours: 8.0 Hours
Unit Overview
This unit focuses on Arrays and String Manipulations, exploring key syntax, structural paradigms, common pitfalls, and practical code implementations.
Essential Concepts:
- Theoretical Foundations: Core definitions, historical rationale, and design architecture.
- Syntax & Examples: Compilable ANSI C code snippets demonstrating real-world usage.
- Common University Questions: Frequently tested questions in TU FOHSS board examinations.
```c /* Practical demonstration for Arrays and String Manipulations */ #include <stdio.h>
void demonstrateConcept(void) { printf("Demonstrating key concepts of: %s ", "Arrays and String Manipulations"); }
int main(void) { demonstrateConcept(); return 0; } ```
Self-Assessment & Review Questions:
- Define the primary mechanics of Arrays and String Manipulations.
- Differentiate between the fundamental paradigms introduced in this chapter.
- Write a short, self-contained C routine illustrating best practices for memory and CPU efficiency.
Unit 6: Functions and Recursion Notes
Course: C Programming (CACS101) | Term: BCA 1st Semester | Teaching Hours: 7.0 Hours
Unit Overview
This unit focuses on Functions and Recursion, exploring key syntax, structural paradigms, common pitfalls, and practical code implementations.
Essential Concepts:
- Theoretical Foundations: Core definitions, historical rationale, and design architecture.
- Syntax & Examples: Compilable ANSI C code snippets demonstrating real-world usage.
- Common University Questions: Frequently tested questions in TU FOHSS board examinations.
```c /* Practical demonstration for Functions and Recursion */ #include <stdio.h>
void demonstrateConcept(void) { printf("Demonstrating key concepts of: %s ", "Functions and Recursion"); }
int main(void) { demonstrateConcept(); return 0; } ```
Self-Assessment & Review Questions:
- Define the primary mechanics of Functions and Recursion.
- Differentiate between the fundamental paradigms introduced in this chapter.
- Write a short, self-contained C routine illustrating best practices for memory and CPU efficiency.
Unit 7: Pointers and Memory Management Notes
Course: C Programming (CACS101) | Term: BCA 1st Semester | Teaching Hours: 8.0 Hours
Unit Overview
This unit focuses on Pointers and Memory Management, exploring key syntax, structural paradigms, common pitfalls, and practical code implementations.
Essential Concepts:
- Theoretical Foundations: Core definitions, historical rationale, and design architecture.
- Syntax & Examples: Compilable ANSI C code snippets demonstrating real-world usage.
- Common University Questions: Frequently tested questions in TU FOHSS board examinations.
```c /* Practical demonstration for Pointers and Memory Management */ #include <stdio.h>
void demonstrateConcept(void) { printf("Demonstrating key concepts of: %s ", "Pointers and Memory Management"); }
int main(void) { demonstrateConcept(); return 0; } ```
Self-Assessment & Review Questions:
- Define the primary mechanics of Pointers and Memory Management.
- Differentiate between the fundamental paradigms introduced in this chapter.
- Write a short, self-contained C routine illustrating best practices for memory and CPU efficiency.
Unit 8: Structures and Unions Notes
Course: C Programming (CACS101) | Term: BCA 1st Semester | Teaching Hours: 5.0 Hours
Unit Overview
This unit focuses on Structures and Unions, exploring key syntax, structural paradigms, common pitfalls, and practical code implementations.
Essential Concepts:
- Theoretical Foundations: Core definitions, historical rationale, and design architecture.
- Syntax & Examples: Compilable ANSI C code snippets demonstrating real-world usage.
- Common University Questions: Frequently tested questions in TU FOHSS board examinations.
```c /* Practical demonstration for Structures and Unions */ #include <stdio.h>
void demonstrateConcept(void) { printf("Demonstrating key concepts of: %s ", "Structures and Unions"); }
int main(void) { demonstrateConcept(); return 0; } ```
Self-Assessment & Review Questions:
- Define the primary mechanics of Structures and Unions.
- Differentiate between the fundamental paradigms introduced in this chapter.
- Write a short, self-contained C routine illustrating best practices for memory and CPU efficiency.
Unit 9: File Handling in C Notes
Course: C Programming (CACS101) | Term: BCA 1st Semester | Teaching Hours: 5.0 Hours
Unit Overview
This unit focuses on File Handling in C, exploring key syntax, structural paradigms, common pitfalls, and practical code implementations.
Essential Concepts:
- Theoretical Foundations: Core definitions, historical rationale, and design architecture.
- Syntax & Examples: Compilable ANSI C code snippets demonstrating real-world usage.
- Common University Questions: Frequently tested questions in TU FOHSS board examinations.
```c /* Practical demonstration for File Handling in C */ #include <stdio.h>
void demonstrateConcept(void) { printf("Demonstrating key concepts of: %s ", "File Handling in C"); }
int main(void) { demonstrateConcept(); return 0; } ```
Self-Assessment & Review Questions:
- Define the primary mechanics of File Handling in C.
- Differentiate between the fundamental paradigms introduced in this chapter.
- Write a short, self-contained C routine illustrating best practices for memory and CPU efficiency.