Course Rationale
This course is designed to build a strong foundation in procedure-oriented programming. It covers algorithms, data structures, control flow, functions, and pointers—essential skills for any aspiring computer engineer.
Unit I: Basics of ‘C’ Programming
1.1 Fundamentals of Algorithms
An algorithm is a step-by-step procedure to solve a specific problem. It acts as a blueprint for your code. Before writing any program, it is crucial to define the logic clearly.
- Pseudocode: Writing the logic in simple English-like statements (e.g., "Set X = 5").
- Flowcharts: Graphical representation using standard symbols (Ovals for Start/Stop, Parallelograms for Input/Output, Rectangles for Process, Diamonds for Decision).
1.2 Structure of a C Program
A C program has a specific structure that the compiler expects:
1.3 Variables, Constants, and Data Types
Variables are named storage locations in memory (e.g., int age = 20;).
Constants are fixed values that do not change during execution (e.g.,
const float PI = 3.14;).
Basic Data Types:
int: Integers (whole numbers). Size: 2 or 4 bytes.float: Decimal numbers. Size: 4 bytes.char: Single characters. Size: 1 byte.double: Large decimal numbers. Size: 8 bytes.
1.4 Input and Output Functions
The stdio.h library provides functions for communication with the user:
printf("formatting string", variables);: Used to display output to the screen.scanf("format specifier", &variable);: Used to take input from the user. Note the usage of&(address-of operator).
Unit II: Control Structures
2.1 Conditional Branching
Decision-making structures allow the program to execute code blocks based on conditions:
if (condition) { ... }: Executes code if the condition is true.if-else: Executes the 'if' block if true, otherwise executes the 'else' block.else-if ladder: Checks multiple conditions in sequence.switch: Selects one of many code blocks to be executed (often used for menu-driven programs).
2.2 Loops (Iterative Statements)
Loops are used to repeat a block of code multiple times:
while loop: Entry-controlled. Checks condition first, then executes.do-while loop: Exit-controlled. Executes once, then checks condition. Essential for menu-driven programs.for loop: Best when the number of iterations is known (Initialization; Condition; Update).
2.3 Jump Statements
Used to transfer control unconditionally:
break;: Exits the loop or switch immediately.continue;: Skips the current iteration and moves to the next one.goto label;: Jumps to a labeled part of the code (generally discouraged).
Unit III: Arrays & Structures
3.1 Arrays
An Array is a collection of elements of the same data type stored in contiguous memory locations.
One-Dimensional Array: List of items (e.g., Marks of 5 students).
int marks[5];
Two-Dimensional Array: Grid or Matrix format (Rows x Columns).
int matrix[3][3];
3.2 Strings
In C, a String is simply a character array terminated by a null character
'\0'.
Common operations include finding length (strlen), copying (strcpy), and
concatenating (strcat).
3.3 Structures
A Structure allows you to combine data of different types under a single name. Consider a student record:
We can create an Array of Structures to store records for multiple students efficiently.
Unit IV: Functions
4.1 Need for Functions
Functions allow modularity. They break large programs into smaller, manageable, and reusable pieces ("Divide and Conquer").
4.2 Types of Functions
- Library Functions: Pre-defined functions (e.g.,
printf(),sqrt(),strlen()). - User-Defined Functions: Functions created by the programmer to perform specific tasks.
4.3 Parameter Passing
- Call by Value: Value of arguments is copied. Changes in the function do not affect the original variable.
- Call by Reference: Address of arguments is passed. Changes do affect the original variable.
4.4 Recursion
Recursion occurs when a function calls itself. It needs a base case to stop infinite
looping. Example: Factorial calculation (5! = 5 * 4!).
Unit V: Pointers
5.1 Introduction to Pointers
A Pointer is a variable that stores the memory address of another variable. It is a powerful feature for direct memory manipulation.
&(Address-of Operator): Returns the address of a variable.*(Dereference Operator): Accesses the value stored at the address.
5.2 Pointer Arithmetic
We can perform addition and subtraction on pointers. Incrementing an integer pointer (ptr++)
moves it forward by 4 bytes (depending on system architecture), pointing to the next integer location.
Exam Question Bank (Important)
Unit I: Basics
- Define Algorithm and Flowchart. Draw the flowchart symbols.
- Explain the structure of a C program with an example.
- Differentiate between 'Variables' and 'Constants'.
- Explain the usage of bitwise operators in C.
Unit II: Control Structures
- Differentiate between 'while' and 'do-while' loop.
- Explain specific use cases for the 'break' and 'continue' statements.
- Write a program to demonstrate the 'switch case' statement for a simple calculator.
- Explain the 'if-else ladder' with syntax and example.
Unit III: Arrays & Structures
- What is a two-dimensional array? How is it initialized?
- Differentiate between 'Array' and 'Structure'.
- Write a program to find the length of a string without using library functions.
- Explain 'Array of Structures' with an application example.
Unit IV: Functions
- Explain 'Call by Value' vs 'Call by Reference'.
- What is Recursion? Write a recursive function to find the factorial of a number.
- Explain scope of variables: Local vs Global.
- List any four string handling library functions with syntax.
Unit V: Pointers
- What is a Pointer? Explain how to declare and initialize it.
- Explain pointer arithmetic with an example.
- How do you access structure members using a pointer?
❓ Frequently Asked Questions
Q: Is this subject difficult?
A: C is a logical language. If you focus on understanding the logic (Algorithms/Flowcharts) first, the coding part becomes easy.
Q: What is the paper pattern?
A: The theory paper is of 70 marks. Unit II and III carry the highest weightage (16 marks each).
Q: Do we need a laptop for this course?
A: While beneficial, you can also practice basic C programs on mobile using online compilers like Programiz or apps like Coding C.