Learn to design algorithms, write structured C code, and solve problems systematically. Covers PDLC, data structures, control flow, functions, arrays, and pointers for solid computing foundations.
By the end of this unit, I will be able to:
Explain the Program Development Life Cycle
Apply control structures
Design algorithms and flowcharts
Use functions and arrays
Write simple C programs
Perform program testing and debugging
Program Development Life Cycle (PDLC)
The structured process for developing software: Problem Definition → Algorithm Design → Coding → Testing & Debugging → Documentation → Maintenance. Understanding the PDLC ensures programs are developed in an organised, reliable, and repeatable way.
Algorithm Design & Flowcharts
Translating real-world problems into step-by-step logical solutions before writing any code. Techniques include pseudocode writing and flowchart drawing using standard symbols (Start/End, Process, Decision, Input/Output). A well-designed algorithm makes coding faster and reduces errors.
Introduction to the C Language
C program structure — preprocessor directives, main() function, statements, and return values. Setting up a development environment (Dev-C++), compiling source code, and running executable programs. Understanding why C is the foundation of operating systems, embedded systems, and networking tools.
Data Types, Variables & Operators
Declaring and using variables of type int, float, char, and double. Understanding memory allocation and the importance of choosing the correct data type. Arithmetic, relational, and logical operators. Type casting and operator precedence.
Control Structures Writing programs that make decisions and repeat actions:
if, if-else, and else-if chains for conditional logic
switch-case for multi-branch selection
for, while, and do-while loops for repetition
break and continue for loop control
Functions
Modular programming using functions — defining, declaring (prototypes), and calling functions. Passing arguments by value. Return types and the return statement. Understanding scope: local vs. global variables. Writing reusable code blocks that make programs easier to read and maintain.
Arrays
Declaring and initialising one-dimensional arrays. Accessing elements using index notation. Using loops to process arrays (sum, search, sort). Introduction to multi-dimensional arrays and character arrays (strings).
Pointers (Introduction)
Understanding memory addresses and pointer variables. The address-of & and dereference * operators. How pointers relate to arrays and why they are central to C programming.
Program 1 — Simple Calculator
A menu-driven program using switch-case that performs addition, subtraction, multiplication, and division on two user-entered numbers. Demonstrates: variables, user input with scanf(), output with printf(), and conditional branching.
/* Simple Calculator — Program 1 */
#include <stdio.h>
int main() {
float num1, num2, result;
int choice;
printf("=== Calculator ===\n");
printf("1. Add 2. Subtract 3. Multiply 4. Divide\n");
printf("Enter choice: "); scanf("%d", &choice);
printf("Enter two numbers: "); scanf("%f %f", &num1, &num2);
if (choice == 1) result = num1 + num2;
else if (choice == 2) result = num1 - num2;
else if (choice == 3) result = num1 * num2;
else if (choice == 4 && num2 != 0) result = num1 / num2;
else { printf("Invalid input or division by zero.\n"); return 1; }
printf("Result: %.2f\n", result);
return 0;
}
Program 2 — Number Pattern Using Loops
A program that prints number patterns (e.g. multiplication tables, triangles) using nested for loops. Demonstrates: loop nesting, loop counters, and formatted output.
/* Multiplication Table — Program 2 */
#include <stdio.h>
int main() {
int n, i;
printf("Enter a number: "); scanf("%d", &n);
printf("\nMultiplication table for %d:\n", n);
for (i = 1; i <= 10; i++) {
printf("%3d x %2d = %4d\n", n, i, n * i);
}
return 0;
}
Program 3 — Grade Classifier
Takes a student's mark as input and outputs the corresponding grade (A, B, C, D, F) using if-else if chains. Demonstrates: relational operators, conditional logic, and user input validation.
/* Grade Classifier — Program 3 */
#include <stdio.h>
int main() {
int mark;
char grade;
printf("Enter mark (0-100): "); scanf("%d", &mark);
if (mark < 0 || mark > 100)
printf("Invalid mark.\n");
else if (mark >= 80) grade = 'A';
else if (mark >= 65) grade = 'B';
else if (mark >= 50) grade = 'C';
else if (mark >= 40) grade = 'D';
else grade = 'F';
if (mark >= 0 && mark <= 100)
printf("Grade: %c\n", grade);
return 0;
}
Program 4 — Array Average Calculator
Reads 10 integers into an array, calculates the sum and average, and identifies the highest and lowest values. Demonstrates: array declaration, loop-based array processing, and function use.
/* Array Average Calculator — Program 4 */
#include <stdio.h>
#define SIZE 10
int main() {
int arr[SIZE], i, sum = 0, min, max;
printf("Enter %d integers:\n", SIZE);
for (i = 0; i < SIZE; i++) scanf("%d", &arr[i]);
min = max = arr[0];
for (i = 0; i < SIZE; i++) {
sum += arr[i];
if (arr[i] < min) min = arr[i];
if (arr[i] > max) max = arr[i];
}
printf("Sum: %d | Average: %.1f | Min: %d | Max: %d\n",
sum, (float)sum/SIZE, min, max);
return 0;
}
Program 5 — Function-Based Unit Converter
Converts between units (e.g. kilometres to miles, Celsius to Fahrenheit) using separate functions for each conversion. Demonstrates: function definition, argument passing, return values, and modular program design.
/* Unit Converter — Program 5 */
#include <stdio.h>
float km_to_miles(float km) { return km * 0.621371; }
float miles_to_km(float mi) { return mi * 1.60934; }
float c_to_f(float c) { return (c * 9.0/5.0) + 32; }
float f_to_c(float f) { return (f - 32) * 5.0/9.0; }
int main() {
int choice; float value;
printf("1.km→mi 2.mi→km 3.C→F 4.F→C\nChoice: ");
scanf("%d", &choice);
printf("Value: "); scanf("%f", &value);
if (choice==1) printf("%.3f miles\n", km_to_miles(value));
else if (choice==2) printf("%.3f km\n", miles_to_km(value));
else if (choice==3) printf("%.1f °F\n", c_to_f(value));
else if (choice==4) printf("%.1f °C\n", f_to_c(value));
return 0;
}