Course Title: Computer Programming L P U
Course Code: TA 116
3 2 4
Course Objective:
To understand the various steps in Program development.
To understand the basic concepts in C Programming Language.
To learn how to write modular and readable C Programs
To learn to write programs (using structured programming approach) in C to solve
problems.
To introduce the students to basic data structures such as lists, stacks and queues.
To make the student understand simple sorting and searching methods.
Unit I: Fundamentals of C Programming
History of C, structure of a C program, execution process, constants, variables, data types,
declarations, assigning values, type conversion, arithmetic operators, relational operators, logical
operators, assignment operators, increment/decrement operators, conditional operators, operator
precedence, formatted input/output, unformatted input/output, decision making with if, if-else,
nested if, and switch-case.
Unit II: Arrays, Strings and Functions
While loop, do-while loop, for loop, array declaration, array initialization, single-dimensional
arrays, two-dimensional arrays, multi-dimensional arrays, string declaration, string initialization,
string operations, character handling, function definition, function calls, return values.
Unit III: Advanced Functions and Pointers
Storage classes, user-defined functions, types of functions, passing arguments, nesting of
functions, recursion, passing arrays to functions, introduction to pointers, pointer declaration,
pointer initialization, accessing addresses, pointer expressions, pointer arithmetic, pointers with
arrays, pointers with strings.
Unit IV: Dynamic Memory, Structures and File Handling
Array of pointers, dynamic memory allocation with malloc, calloc, realloc, free, structures
definition, initialization of structures, operations on structures, arrays of structures, unions,
bitwise operators, bit fields, macros, file handling, opening files, closing files, file input/output
operations.
Unit V: Data Handling and Searching/Sorting
Random access to files, command line arguments, linear search, binary search, selection sort,
bubble sort, introduction to trees, introduction to graphs.
Text Books:
T1: Programming with ANSI C, E. E. Balaguruswamy , TMH, 6th Ed. 2009
Balaguruswamy
R1: The C Programming Language Kernigham and Richie , PHI 2nd Ed. 2002
R2: Let us C Yashwanth Kanithkar, BPB Publications, 8th Edition
Recommended Lab Exercises
1. Basic Program Structure
Write a simple C program to display "Hello, World!" and understand the structure of a C
program (including header files, main function, and return statements).
Topics: History, Basic structure, Execution.
2. Working with Constants and Variables
Write a program to declare and initialize different types of constants and variables.
Perform arithmetic operations using variables.
Topics: Constants, Variables, Data types.
3. Operators and Expressions
Create a program that demonstrates the use of arithmetic, relational, logical, and
conditional operators.
Write a program to showcase type conversion and operator precedence.
Topics: Operators, Expressions, Type conversion.
4. Input/Output Operations
Write a program to read a character, a word, and a sentence from the user and display the
same.
Create a program using formatted and unformatted I/O functions.
Topics: Input/output operations.
5. Decision Making and Branching
Write a program using if and if-else to check whether a given number is even or odd.
Create a calculator program using the switch-case statement.
Topics: Decision making, Branching.
6. Looping Constructs
Write a program using for loop to calculate the factorial of a number.
Use a while loop to find the reverse of a given number.
Implement a do-while loop to display the multiplication table of a number.
Topics: While, Do-while, For loops.
7. Single and Multidimensional Arrays
Write a program to perform matrix addition using 2D arrays.
Implement a program to find the largest and smallest elements in a single-dimensional
array.
Topics: Arrays.
8. String Operations
Write a program to concatenate two strings without using library functions.
Implement a program to check if a string is a palindrome.
Topics: Strings and characters.
9. Functions and Recursion
Write a program to calculate the GCD of two numbers using a user-defined function.
Implement a recursive function to find the Fibonacci series up to a given number.
Topics: Functions, Recursion.
10. Pointers Basics
Write a program to display the address of variables using pointers.
Use a pointer to modify the value of a variable.
Topics: Pointers, Pointer expressions.
11. Pointers with Arrays and Strings
Write a program to find the sum of all elements in an array using pointers.
Implement a program to reverse a string using a pointer.
Topics: Pointers and arrays, Pointers and strings.
12. Dynamic Memory Allocation
Write a program to dynamically allocate memory for an integer array using malloc and
calculate the sum of the elements.
Use calloc to allocate memory for a structure containing student data (name, roll, and
marks).
Topics: Malloc, Calloc, Free, Realloc.
13. Structures and Unions
Write a program to store and display information of n employees using structures.
Create a program demonstrating the use of a union to store different types of data in a
memory-efficient way.
Topics: Structures, Unions.
14. File Handling
Write a program to create a file and write data to it.
Implement a program to read from a file and count the number of words and lines.
Write a program to demonstrate random file access and command-line arguments.
Topics: File operations, Command-line arguments.
15. Bitwise Operations
Write a program to demonstrate the use of bitwise operators (AND, OR, XOR, shift
operations).
Implement a program using macros to calculate the area of a circle and rectangle.
Topics: Bitwise operators, Macros.