Official Class 12 Computer Science Worksheets: Program List
Review targeted academic worksheets with the CBSE Class 12 Computer Science Program List Worksheet. Built according to official educational standards for the 2026-27 term, these downloadable Class 12 Computer Science resources support effective daily practice and detailed self-evaluation for Program List.
Solved Practice Worksheets for Computer Science
Navigate directly to the solved Computer Science worksheets using the digital viewer below. Each practice set includes detailed step-by-step solutions, allowing students to instantly cross-check their work and identify areas requiring further revision.
Program List
Function Overloading
Question (i). Write a program to do the following using function overloading.
(a) To implement area of circle.
(b) To implement area of rectangle
(c) To implement area of triangle
Answer:
```cpp #include
In simple words: This program computes the area of different geometric shapes using the same function name, area. C++ chooses which function to run based on the count of arguments provided.
Exam Tip: To score full marks on function overloading questions, ensure that each function signature has a completely unique parameter list so the compiler can successfully resolve the call.
Classes & Objects
Question (i). Declare a class employee of 10 arrays of objects having following members:
Private() Members:
- Empcode (integer)
- Empname (20 character)
- Empdesig (20 character)
- Empsalary (float)
- Hra, da (float)
- cal_hra(void): A function to calculate house rent allowance
- cal_gross(void): A function to calculate gross salary
Public Members:
- Cal_da(): A function to calculate da with void return type public member function of class employee
- input_data(): function to accept values for empcode, empname, empdesign, empsalary, hra, da
- Display(void): function t display all the data member on the screen & invoke input_data()
Answer:
```cpp #include
In simple words: This code sets up an employee database record with hidden calculations (like HRA) and public methods to read inputs and display outputs for a list of ten workers.
Exam Tip: Be sure to keep private helper methods inside the private section of your class diagram, as only public interface functions should be directly accessible by external class objects.
Question (ii). Write a program to input on students information & to do total & grade calculation using class.
Answer:
```cpp #include
In simple words: This program uses a Student class to accept student details, aggregate subject marks into a final percentage, assign a grade letter, and print the scorecard.
Exam Tip: Place data manipulation and mathematical calculations inside private utility helper methods to reinforce the object-oriented principle of encapsulation.
Constructor & Destructors
Question. Define a class Play in C++ with the following specifications:
Private members of class Play
Playcode integer
PlayTitle 25 character
Duration float
Noofscenes integer
Public member function to class Play
• A constructor function to initialize Duration as 45 and Noofscenes as 5
• Newplay( ) function to accept values for Playcode and PlayTitle
• Moreinfo( ) function to assign the values of Duration and Noofscenes with the help of corresponding values passed as parameters to this function.
• Shoplay( ) function to display all the data members on the screen
Answer:
```cpp #include
In simple words: This code creates a theatrical play class. When initialized, the play has a default length of 45 minutes and 5 scenes, which can be modified using custom update functions.
Exam Tip: Constructors do not possess return types (not even void) and must be defined with the exact same name as the class itself.
File Handling
Question (i). Write a program to count the presence of a word “do” in a text file “memo.txt”.
Example:
If the content of the file “MEMO.TXT” is as follows:
I will do it, if you
request me to do it.
It would have been done much earlier.
The function COUNT_DO( ) will display the following message:
Count of – do – in file:2
Note: In the above example, ‘do’ occurring as a part of word done is not considered.
Answer:
```cpp #include
In simple words: This program opens a file called memo.txt, reads it word-by-word, strips punctuation (like periods or commas), and increments a counter when it locates the standalone word do.
Exam Tip: Be sure to clean punctuation marks using the standard functions to ensure words like 'do,' and 'do.' are successfully parsed and counted.
Question (ii). Write a program in C++ to count and display the number of lines starting with alphabet ‘A’ present in a text file “LINES.TXT”.
Example:
if the file “LINES.TXT” contains the following lines,
A boy is playing there.
There is a playground.
An aeroplane is in the sky.
Alphabets and numbers are allowed in the password.
The function should display the output as 3
Answer:
```cpp #include
In simple words: This script opens LINES.TXT and scans it line-by-line, adding to our counter every time a line begins with the letter A (either capital or small).
Exam Tip: Always make sure to verify that the line length is greater than zero (`line.length() > 0`) before inspecting the index `line[0]` to avoid empty-string runtime errors.
Question (iii). Create a structure Employee:
Name - 20 character
Salary - Float
Empno - 4 Character
Write a function to create file “tempEmp.Dat” which will copy the Employee records from file “Emp.dat” in reverse order.
Answer:
```cpp #include
In simple words: This code reads binary employee objects from a file into temporary system memory, then iterates through them backward to save them into a new target file.
Exam Tip: For binary files, use the `read()` and `write()` methods with typecasting `(char*)&emp` to preserve precise bit configurations.
Question (iv). Write a program to search any employee information from the file.
Answer:
```cpp #include
In simple words: This program allows you to search for an employee by their ID card code. It scans the database binary file and prints their name and salary if it finds a match.
Exam Tip: Since character arrays in legacy C-style structures are not standard C++ strings, use `strncmp()` or `strcmp()` to compare ID codes accurately.
Question (v). Write a program to delete any employee information from the file.
Answer:
```cpp #include
In simple words: To delete a record, we copy every single employee except the chosen one into a temporary file, discard the old file, and rename the temporary file.
Exam Tip: Be sure to close both file streams before using the `remove()` and `rename()` methods; otherwise, the file locks may prevent changes from saving.
Question (vi). Write a program to modify any employee information.
Answer:
```cpp #include
In simple words: This code finds a target employee, requests new details from the keyboard, adjusts the file write position backward by one object size, and overwrites the target data.
Exam Tip: Use the relative seek `file.seekp(-sizeof(Employee), ios::cur)` to shift the file pointer back to the beginning of the record you just read so you can overwrite it.
Question (vii). Write a program to appends information to a file.
Answer:
```cpp #include
In simple words: This program uses the append option (`ios::app`) to add a new employee entry safely onto the end of the existing file without altering prior data.
Exam Tip: Always open your output stream with `ios::app` to prevent the compiler from overwriting or clearing existing file contents.
Question (viii). Write a program that displays the size of a file in bytes.
Answer:
```cpp #include
In simple words: By opening the file immediately at the end (`ios::ate`) and asking C++ for the index position, we can quickly find the exact size of the file in bytes.
Exam Tip: Combining `ios::ate` with `tellg()` is much faster and cleaner than reading the entire file byte-by-byte in a loop to find its size.
Question (ix). Write a program that copies one file to another.
Answer:
```cpp #include
In simple words: This code copies an existing file by reading its contents character-by-character and saving them directly into a backup file.
Exam Tip: Use the binary stream mode `ios::binary` during copy operations to prevent formatting issues with non-text files.
Arrays
Question (i). Write a program to demonstrate a linear search method of element in an array.
Answer:
```cpp #include
In simple words: This search method checks each item in the array one-by-one from the beginning until it locates the target value or reaches the end.
Exam Tip: Linear search is best for unsorted list structures. It has a worst-case time complexity of O(N).
Question (ii). Write a program to find an element with binary search method in an array list of range. Note that before sorting, your list range should have been sorted.
Answer:
```cpp #include
In simple words: This search method divides a sorted list in half repeatedly. It compares the midpoint value to the target to discard half of the search space in each step.
Exam Tip: Always make sure to emphasize that binary search requires a sorted list. It has an efficient time complexity of O(log N).
Question (iii). Write a program to insert an integer value in an array named range in a particular location.
Answer:
```cpp #include
In simple words: To insert a value, we shift all elements to the right from the target spot onward, insert the new number, and update the active size.
Exam Tip: Be sure to run your shift loop backward from the active size (`i = size`) to avoid overwriting existing values.
Question (iv). Write a program to delete an integer value from an array named range of a particular location.
Answer:
```cpp #include
In simple words: To delete an element, we shift all values after the target location one spot to the left, which overwrites the unwanted value.
Exam Tip: Ensure that your shift loop stops at index `size - 1` to prevent reading past the end of the array.
Question (v). Write a program to sort an array using selection sort.
Answer:
```cpp #include
In simple words: This sorting method repeatedly scans the unsorted part of the list to locate the smallest element and swaps it into its correct final position.
Exam Tip: Selection sort performs a maximum of O(N) swaps, which makes it ideal for situations where writing to memory is slow or expensive.
Question (vi). Write a program to sort an array using bubble sort.
Answer:
```cpp #include
In simple words: This method compares adjacent elements and swaps them if they are out of order, bubbling the largest unsorted value to the end in each pass.
Exam Tip: Bubble sort is a stable sorting algorithm with a standard time complexity of O(N²).
Question (vii). Write a program to sort an array using insertion sort.
Answer:
```cpp #include
In simple words: This sorting algorithm works like sorting playing cards. It takes one element at a time and inserts it into its correct position in the sorted part of the array.
Exam Tip: Insertion sort is highly efficient for small or nearly sorted datasets, achieving near-linear performance of O(N) in best-case scenarios.
Question (viii). Write a program for MERGE sort operation by using two sorted arrays in ascending order.
Answer:
```cpp #include
In simple words: This function merges two pre-sorted lists into a single sorted target array by comparing the front elements of both lists step-by-step.
Exam Tip: Remember to write the cleanup loops that copy any remaining elements after one of the source arrays has been completely exhausted.
Data Structure
Question (i). Write a program to create and traverse the linked list. The linked list contains data of type integer.
Answer:
```cpp #include
In simple words: A linked list consists of nodes where each node holds an integer value and points to the next node. We print the list by following these pointers until we hit NULL.
Exam Tip: Always make sure to use a temporary pointer for traversal so you don't lose track of the list's `head` pointer.
Question (ii). Write a program in C++ to perform the PUSH AND POP operation on linked stack. The stack contains data of type integer.
Answer:
```cpp #include
In simple words: This code uses dynamic nodes to build a stack (LIFO). We push elements onto the top and pop them off, updating the top pointer each time.
Exam Tip: Check for stack underflow (`top == NULL`) before trying to delete elements or redirect pointers during a POP operation.
Question (iii). Write a program to create a queue using linked list to perform the addition, deletion, and display operations.
Answer:
```cpp #include
In simple words: A queue adds elements at the rear and deletes them from the front (FIFO). This linked queue dynamically adds nodes at the back and deletes them from the front.
Exam Tip: Always make sure to set the rear pointer to NULL if removing the last node makes the queue completely empty.
Free study material for Computer Science
Program List Printable Worksheets and Exercises for Class 12 Computer Science
Practice Exercises for Class 12 Computer Science Program List
Explore reliable practice questions for Program List tailored for Class 12 Computer Science learners. Use these structured worksheets to evaluate exam preparedness and strengthen problem-solving skills throughout the 2026 academic session.
Step-by-Step Solutions and Practice Guidelines
Built using official NCERT guidelines for Class 12 Computer Science, these practice sheets provide reliable academic support. Cross-reference your completed work with our detailed solutions to learn standard answer-writing formats for CBSE exams.
Enhance Speed with Online Practice
Wrap up your chapter revision by testing your knowledge against standard objective question formats. Explore our full library of free, up-to-date printable assignments to maximize your academic results in upcoming CBSE evaluations.
FAQs
You can download the latest chapter-wise printable worksheets for Class 12 Computer Science Program List for free from StudiesToday.com. These have been made as per the latest CBSE curriculum for this academic year.
Yes, Class 12 Computer Science worksheets for Program List focus on activity-based learning and also competency-style questions. This helps students to apply theoretical knowledge to practical scenarios.
Yes, we have provided solved worksheets for Class 12 Computer Science Program List to help students verify their answers instantly.
Yes, our Class 12 Computer Science test sheets are mobile-friendly PDFs and can be printed by teachers for classroom.
For Program List, regular practice with our worksheets will improve question-handling speed and help students understand all technical terms and diagrams.