💻💻 Software Development in C Language – Notes
1. Introduction
• C Language → Developed by Dennis Ritchie (1972, Bell Labs).
• General-purpose, procedural, compiled, mid-level language.
• Used in system programming, embedded systems, OS development, and
application software.
2. Software Development Life Cycle (SDLC) in C
1. Requirement Analysis → Understand problem & specifications.
2. Design → Flowcharts, algorithms, pseudo-code.
3. Implementation (Coding) → Writing C programs.
4. Compilation & Testing → Using GCC, Turbo C, etc.
5. Debugging & Maintenance → Fixing errors, optimizing code.
3. Structure of a C Program
#include <stdio.h> // Preprocessor directive
int main() { // Entry point
printf("Hello, World!\n");
return 0; // Exit status
}
Steps in Compilation:
Source Code → Preprocessor → Compiler → Assembler → Linker → Executable
4. Basic Building Blocks
• Keywords: int, float, char, if, else, for, while, return, void, struct, etc.
• Identifiers: User-defined names (variables, functions).
• Constants & Variables:
• const double PI = 3.14;
• int age = 25;
• Data Types:
o int, float, double, char
o Derived: arrays, pointers, structures, unions
5. Operators
• Arithmetic: + - * / %
• Relational: == != > < >= <=
• Logical: && || !
• Assignment: = += -=
• Bitwise: & | ^ << >>
• Increment/Decrement: ++ --
6. Control Structures
Conditional
if (a > b) { ... }
else if (a == b) { ... }
else { ... }
Switch
switch(choice) {
case 1: printf("One"); break;
default: printf("Invalid");
}
Loops
• for → counter controlled
• while → condition controlled
• do-while → executes at least once
7. Functions
int add(int a, int b) {
return a + b;
}
• Library functions → printf(), scanf(), strlen()
• User-defined functions → programmer-defined
• Call by Value vs Call by Reference (using pointers)
8. Arrays & Strings
Arrays
int arr[5] = {10,20,30,40,50};
Strings
char name[] = "C Programming";
printf("%s", name);
String functions: strlen(), strcpy(), strcat(), strcmp()
9. Pointers
• Variable storing memory address.
int x = 10;
int *ptr = &x;
printf("%d", *ptr); // Dereferencing
• Used in arrays, functions, dynamic memory, data structures.
10. Structures & Unions
struct Student {
int id;
char name[20];
};
• Structure → groups different data types.
• Union → memory shared by all members.
11. File Handling
FILE *fp;
fp = fopen("data.txt", "w");
fprintf(fp, "Hello C");
fclose(fp);
Modes: "r", "w", "a", "r+", "w+"
Functions: fopen(), fclose(), fprintf(), fscanf(), fgetc(), fputc()
12. Memory Management
• malloc() → allocate memory
• calloc() → allocate & initialize
• realloc() → resize
• free() → release memory
13. Error Handling & Debugging
• Compile-time errors → syntax issues
• Run-time errors → divide by zero, invalid memory
• Logical errors → wrong output
• Tools: gdb debugger, assert.h, logging
14. Software Development Practices in C
• Modular Programming → breaking into functions/files.
• Code Reusability → header files, libraries.
• Documentation & Comments → // single line or /* block */.
• Testing → Unit testing (individual modules).
• Version Control → Git for project collaboration.
15. Applications of C
• Operating Systems (Unix, Linux, Windows parts).
• Compilers, Interpreters.
• Embedded Systems.
• Database Systems (e.g., MySQL core).
• Game Development.