Computer Programming Lab Manual
Computer Programming Lab Manual
Description: This lab aims to familiarize students with the fundamental structure of C programs, basic
data types, and input/output operations.
Steps:
2. Write a program to accept two numbers from the user and display their sum.
3. Write a program to find the area of a rectangle given its length and width.
Description: This lab focuses on conditional statements, loops, and controlling loop execution using break
and continue statements.
Steps:
2. Write a program to find the largest of three numbers using if-else statements.
3. Write a program to print the Fibonacci series up to a given number using a while loop.
4. Write a program to print the multiplication table of a given number using a for loop.
Description: This lab introduces students to user-defined functions, passing arguments, and the scope
and lifetime of variables.
Steps:
1. Write a program to find the sum of digits of a number using a user-defined function.
3. Write a program to swap two numbers using call by value and call by reference.
4. Write a program to find the maximum and minimum elements in an array using functions.
5. Write a program to check whether a given number is prime or not using functions.
Lab 4: Arrays and Pointers in C
Description: This lab covers the declaration and usage of arrays, pointers, dynamic memory allocation,
and multi-dimensional arrays.
Steps:
Description: This lab introduces students to defining and using structures, nesting structures and arrays
within structures, and the basics of unions.
Steps:
1. Write a program to define a structure for a student record containing name, roll number, and
marks in three subjects.
2. Write a program to calculate the area and perimeter of a rectangle using a structure.
4. Write a program to define a union for storing integer and float values and display its size.
5. Write a program to implement a simple calculator using a union for arithmetic operations.
Lab 6: Introduction to Object-Oriented Programming (OOP) Principles
Description: This lab introduces students to the concepts of objects, classes, encapsulation, and
abstraction.
Steps:
3. Write a program to implement a basic class representing a bank account with deposit and
withdrawal functions.
4. Write a program to demonstrate abstraction by implementing a class for a shape with functions
to calculate area and perimeter.
5. Write a program to demonstrate encapsulation by implementing a class for a car with private data
members and public member functions for accessing them.
Lab 7: Functions and Pointers in OOP
Description: This lab covers function pointers, creating callbacks, and implementing polymorphism in C
using function overriding.
Steps:
1. Write a program to demonstrate function pointers by implementing a simple calculator with add,
subtract, multiply, and divide functions.
2. Write a program to implement a callback function to handle button clicks in a graphical user
interface.
4. Write a program to implement a simple text editor with functions for open, save, and close using
function pointers.
5. Write a program to implement a menu-driven application using function pointers for different
menu options.
Lab 8: Creating Classes in C
Description: This lab focuses on designing classes, defining data members, member functions,
constructors, and destructors.
Steps:
1. Write a program to define a class for a circle with data members radius and center and member
functions to calculate area and circumference.
2. Write a program to implement constructors and destructors for the circle class.
3. Write a program to define a class for a complex number with data members real and imaginary
parts and member functions to add, subtract, multiply, and divide complex numbers.
4. Write a program to demonstrate the use of default constructor and parameterized constructor
for initializing objects.
5. Write a program to define a class for a bank account with data members account number,
balance, and member functions for deposit, withdraw, and display balance.
Lab 9: Inheritance and Reusability in C
Description: This lab focuses on achieving inheritance through structures and using function pointers for
inherited functions.
Steps:
1. Write a program to demonstrate inheritance by creating a base class for a shape with data
members for dimensions and a derived class for a rectangle inheriting from the shape class.
2. Write a program to implement function pointers for inherited functions to calculate area and
perimeter of shapes.
3. Write a program to define a base class for a vehicle with data members for make, model, and year
and derived classes for car and bike inheriting from the vehicle class.
5. Write a program to implement a simple payroll system with base classes for employee and
manager and derived classes for full-time and part-time employees inheriting from the employee
class.
Lab 10: Polymorphism and Interfaces in C
Description: This lab covers polymorphism with function pointers and creating interfaces by defining
function signatures.
Steps:
1. Write a program to demonstrate polymorphism using function pointers for different operations
on shapes.
2. Write a program to implement an interface for a shape with function signatures for area and
perimeter calculations.
3. Write a program to define interfaces for printable objects with function signatures for printing to
console and file.
4. Write a program to implement polymorphism for printable objects using function pointers.
5. Write a program to implement a simple graphical user interface with interface functions for
drawing shapes and text.
Lab 11: File Handling in C
Description: This lab focuses on reading from and writing to files, manipulating file pointers, and handling
errors during file operations.
Steps:
1. Write a program to create a text file and write data into it.
2. Write a program to read data from a text file and display it on the console.
5. Write a program to search for a specific string in a text file and display its occurrences.
Lab 12: Dynamic Memory Allocation in C
Description: This lab covers dynamic memory allocation using functions like malloc, calloc, realloc, and
freeing dynamically allocated memory using free.
Steps:
1. Write a program to dynamically allocate memory for an array of integers and display its contents.
2. Write a program to dynamically allocate memory for a string and copy one string into another.
3. Write a program to dynamically allocate memory for a 2D array and perform matrix operations.
4. Write a program to create a linked list dynamically and perform basic operations like insertion,
deletion, and traversal.
5. Write a program to implement a stack using dynamic memory allocation and perform push and
pop operations.
Lab 13-15: Application Development and Projects
Objective: To apply the concepts learned in the course to real-world problems and projects.
Description: Students will work on individual or group projects that require them to design, implement,
and test C and C++ programs addressing specific requirements or solving particular problems.
Steps:
1. Choose a project topic or problem statement related to the concepts learned in the course.
2. Design the program structure, classes, and functions needed to solve the problem.
5. Document the project including requirements, design decisions, implementation details, testing
results, and user manuals.