CBSE Class 12 Computer Science Program List Worksheet

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 #include using namespace std; // Overloaded function for Area of Circle double area(double radius) { return 3.14159 * radius * radius; } // Overloaded function for Area of Rectangle double area(double length, double breadth) { return length * breadth; } // Overloaded function for Area of Triangle (using Heron's Formula) double area(double side1, double side2, double side3) { double s = (side1 + side2 + side3) / 2.0; return sqrt(s * (s - side1) * (s - side2) * (s - side3)); } int main() { cout << "Area of Circle (r = 5): " << area(5.0) << endl; cout << "Area of Rectangle (l = 4, b = 6): " << area(4.0, 6.0) << endl; cout << "Area of Triangle (sides 3, 4, 5): " << area(3.0, 4.0, 5.0) << endl; return 0; } ```
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 #include using namespace std; class employee { private: int Empcode; char Empname[20]; char Empdesig[20]; float Empsalary; float hra; float da; void cal_hra() { // HRA is calculated as 15% of basic salary hra = 0.15 * Empsalary; } void cal_gross() { float gross = Empsalary + hra + da; cout << "Gross Salary: " << gross << endl; } public: void Cal_da() { // DA is calculated as 50% of basic salary da = 0.50 * Empsalary; } void input_data() { cout << "Enter Employee Code: "; cin >> Empcode; cin.ignore(); cout << "Enter Employee Name: "; cin.getline(Empname, 20); cout << "Enter Designation: "; cin.getline(Empdesig, 20); cout << "Enter Basic Salary: "; cin >> Empsalary; // Calculate HRA and DA based on input salary cal_hra(); Cal_da(); } void Display() { cout << "\n--- Employee Details ---" << endl; cout << "Code: " << Empcode << endl; cout << "Name: " << Empname << endl; cout << "Designation: " << Empdesig << endl; cout << "Basic Salary: " << Empsalary << endl; cout << "HRA: " << hra << endl; cout << "DA: " << da << endl; cal_gross(); } }; int main() { employee empList[10]; cout << "Enter details for 10 employees:" << endl; for (int i = 0; i < 10; i++) { cout << "\nEmployee " << (i + 1) << ":" << endl; empList[i].input_data(); } cout << "\nDisplaying Employee Records:" << endl; for (int i = 0; i < 10; i++) { empList[i].Display(); } return 0; } ```
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 #include using namespace std; class Student { int rollNo; string name; float marks[5]; float total; float percentage; char grade; void calculate() { total = 0; for (int i = 0; i < 5; i++) { total += marks[i]; } percentage = total / 5.0; if (percentage >= 90) grade = 'A'; else if (percentage >= 75) grade = 'B'; else if (percentage >= 50) grade = 'C'; else grade = 'D'; } public: void input() { cout << "Enter Roll Number: "; cin >> rollNo; cin.ignore(); cout << "Enter Name: "; getline(cin, name); cout << "Enter Marks for 5 Subjects: " << endl; for (int i = 0; i < 5; i++) { cout << "Subject " << (i + 1) << ": "; cin >> marks[i]; } calculate(); } void display() { cout << "\nStudent Record:" << endl; cout << "Roll No: " << rollNo << endl; cout << "Name: " << name << endl; cout << "Total Marks: " << total << "/500" << endl; cout << "Percentage: " << percentage << "%" << endl; cout << "Grade: " << grade << endl; } }; int main() { Student s; s.input(); s.display(); return 0; } ```
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 #include using namespace std; class Play { private: int Playcode; char PlayTitle[25]; float Duration; int Noofscenes; public: // Constructor Function Play() { Duration = 45; Noofscenes = 5; } // Function to accept initial values void Newplay() { cout << "Enter Play Code: "; cin >> Playcode; cin.ignore(); cout << "Enter Play Title: "; cin.getline(PlayTitle, 25); } // Function to assign duration and scenes via parameters void Moreinfo(float dur, int scenes) { Duration = dur; Noofscenes = scenes; } // Function to display play data void Shoplay() { cout << "\nPlay Details:" << endl; cout << "Code: " << Playcode << endl; cout << "Title: " << PlayTitle << endl; cout << "Duration: " << Duration << " mins" << endl; cout << "No. of Scenes: " << Noofscenes << endl; } }; int main() { Play p; p.Newplay(); p.Shoplay(); p.Moreinfo(90, 8); p.Shoplay(); return 0; } ```
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 #include #include #include using namespace std; // Function to strip punctuation from a word string cleanWord(string word) { string cleaned = ""; for (int i = 0; i < word.length(); i++) { if (isalnum(word[i])) { cleaned += tolower(word[i]); } } return cleaned; } void COUNT_DO() { ifstream file("memo.txt"); if (!file) { cout << "Error: Unable to open memo.txt file." << endl; return; } string word; int count = 0; while (file >> word) { if (cleanWord(word) == "do") { count++; } } cout << "Count of - do - in file: " << count << endl; file.close(); } int main() { COUNT_DO(); return 0; } ```
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 #include #include using namespace std; void countLinesWithA() { ifstream file("LINES.TXT"); if (!file) { cout << "Error: Unable to open LINES.TXT" << endl; return; } string line; int count = 0; while (getline(file, line)) { if (line.length() > 0 && (line[0] == 'A' || line[0] == 'a')) { count++; } } cout << "The function should display the output as " << count << endl; file.close(); } int main() { countLinesWithA(); return 0; } ```
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 #include #include using namespace std; struct Employee { char Name[20]; float Salary; char Empno[4]; }; void copyReverse() { ifstream inFile("Emp.dat", ios::binary); if (!inFile) { cout << "Error: Could not open Emp.dat source file." << endl; return; } vector tempVector; Employee emp; // Read all records from standard binary file while (inFile.read((char*)&emp, sizeof(Employee))) { tempVector.push_back(emp); } inFile.close(); ofstream outFile("tempEmp.Dat", ios::binary); if (!outFile) { cout << "Error: Could not create tempEmp.Dat file." << endl; return; } // Write records to the new binary file in reverse order for (int i = tempVector.size() - 1; i >= 0; i--) { outFile.write((char*)&tempVector[i], sizeof(Employee)); } cout << "Reversed file copy created successfully!" << endl; outFile.close(); } int main() { copyReverse(); return 0; } ```
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 #include #include using namespace std; struct Employee { char Name[20]; float Salary; char Empno[4]; }; void searchEmployee(const char targetNo[]) { ifstream file("Emp.dat", ios::binary); if (!file) { cout << "Error: Unable to open Emp.dat file." << endl; return; } Employee emp; bool found = false; while (file.read((char*)&emp, sizeof(Employee))) { if (strncmp(emp.Empno, targetNo, 4) == 0) { cout << "\nEmployee Record Found!" << endl; cout << "No: " << emp.Empno << endl; cout << "Name: " << emp.Name << endl; cout << "Salary: " << emp.Salary << endl; found = true; break; } } if (!found) { cout << "Employee with Code " << targetNo << " not found." << endl; } file.close(); } int main() { char searchNo[4]; cout << "Enter Employee Code to search (4 chars): "; cin >> searchNo; searchEmployee(searchNo); return 0; } ```
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 #include #include using namespace std; struct Employee { char Name[20]; float Salary; char Empno[4]; }; void deleteEmployee(const char targetNo[]) { ifstream inFile("Emp.dat", ios::binary); if (!inFile) { cout << "Error: Emp.dat file not found." << endl; return; } ofstream tempFile("temp.dat", ios::binary); Employee emp; bool deleted = false; // Read and copy all records except the one to delete while (inFile.read((char*)&emp, sizeof(Employee))) { if (strncmp(emp.Empno, targetNo, 4) != 0) { tempFile.write((char*)&emp, sizeof(Employee)); } else { deleted = true; } } inFile.close(); tempFile.close(); // Remove old file and rename the temporary file remove("Emp.dat"); rename("temp.dat", "Emp.dat"); if (deleted) { cout << "Employee ID " << targetNo << " deleted successfully." << endl; } else { cout << "Record not found to delete." << endl; } } int main() { char delNo[4]; cout << "Enter Employee ID to delete: "; cin >> delNo; deleteEmployee(delNo); return 0; } ```
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 #include #include using namespace std; struct Employee { char Name[20]; float Salary; char Empno[4]; }; void modifyEmployee(const char targetNo[]) { fstream file("Emp.dat", ios::binary | ios::in | ios::out); if (!file) { cout << "Error: Unable to open Emp.dat file." << endl; return; } Employee emp; bool modified = false; while (file.read((char*)&emp, sizeof(Employee))) { if (strncmp(emp.Empno, targetNo, 4) == 0) { cout << "Current Name: " << emp.Name << ", Salary: " << emp.Salary << endl; cout << "Enter New Name: "; cin.ignore(); cin.getline(emp.Name, 20); cout << "Enter New Salary: "; cin >> emp.Salary; // Reposition write pointer back to update the current record file.seekp(-static_cast(sizeof(Employee)), ios::cur); file.write((char*)&emp, sizeof(Employee)); modified = true; break; } } if (modified) { cout << "Employee details updated successfully!" << endl; } else { cout << "Employee not found." << endl; } file.close(); } int main() { char modNo[4]; cout << "Enter Employee Code to modify: "; cin >> modNo; modifyEmployee(modNo); return 0; } ```
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 #include using namespace std; struct Employee { char Name[20]; float Salary; char Empno[4]; }; void appendEmployee() { ofstream file("Emp.dat", ios::binary | ios::app); if (!file) { cout << "Error opening file." << endl; return; } Employee emp; cout << "Enter Employee Number (4 characters): "; cin >> emp.Empno; cin.ignore(); cout << "Enter Name: "; cin.getline(emp.Name, 20); cout << "Enter Salary: "; cin >> emp.Salary; file.write((char*)&emp, sizeof(Employee)); cout << "New record appended successfully!" << endl; file.close(); } int main() { appendEmployee(); return 0; } ```
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 #include using namespace std; void displayFileSize() { ifstream file("Emp.dat", ios::binary | ios::ate); if (!file) { cout << "Error: Could not open file to determine size." << endl; return; } // tellg() retrieves current file position as we opened it at the end (ios::ate) long size = file.tellg(); cout << "Size of file is " << size << " bytes." << endl; file.close(); } int main() { displayFileSize(); return 0; } ```
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 #include using namespace std; void copyFile() { ifstream src("Emp.dat", ios::binary); if (!src) { cout << "Error opening source file." << endl; return; } ofstream dest("Emp_backup.dat", ios::binary); if (!dest) { cout << "Error creating backup destination file." << endl; src.close(); return; } char ch; // Copy the file character-by-character while (src.get(ch)) { dest.put(ch); } cout << "File duplicated successfully!" << endl; src.close(); dest.close(); } int main() { copyFile(); return 0; } ```
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 using namespace std; int linearSearch(int arr[], int size, int element) { for (int i = 0; i < size; i++) { if (arr[i] == element) { return i; // Element found, return index } } return -1; // Element not found } int main() { int arr[] = {34, 12, 5, 89, 2, 77}; int target = 89; int index = linearSearch(arr, 6, target); if (index != -1) { cout << "Element " << target << " found at index: " << index << endl; } else { cout << "Element " << target << " not found." << endl; } return 0; } ```
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 using namespace std; int binarySearch(int arr[], int size, int target) { int low = 0; int high = size - 1; while (low <= high) { int mid = low + (high - low) / 2; if (arr[mid] == target) return mid; else if (arr[mid] < target) low = mid + 1; else high = mid - 1; } return -1; } int main() { // Array must be sorted before performing binary search int sortedArr[] = {2, 5, 12, 34, 77, 89}; int target = 77; int index = binarySearch(sortedArr, 6, target); if (index != -1) { cout << "Element " << target << " found at index: " << index << endl; } else { cout << "Element not found." << endl; } return 0; } ```
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 using namespace std; void insertElement(int arr[], int &size, int capacity, int value, int location) { if (size >= capacity) { cout << "Error: Array is at max capacity." << endl; return; } if (location < 0 || location > size) { cout << "Error: Invalid location index." << endl; return; } // Shift elements to the right to make space for (int i = size; i > location; i--) { arr[i] = arr[i - 1]; } arr[location] = value; size++; // Update active size } int main() { int range[10] = {10, 20, 30, 40, 50}; int size = 5; insertElement(range, size, 10, 25, 2); cout << "Array after insertion: "; for (int i = 0; i < size; i++) { cout << range[i] << " "; } cout << endl; return 0; } ```
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 using namespace std; void deleteElement(int arr[], int &size, int location) { if (location < 0 || location >= size) { cout << "Error: Out of bounds." << endl; return; } // Shift elements left to overwrite target value for (int i = location; i < size - 1; i++) { arr[i] = arr[i + 1]; } size--; // Decrement active size } int main() { int range[10] = {10, 20, 25, 30, 40, 50}; int size = 5; deleteElement(range, size, 2); cout << "Array after deletion: "; for (int i = 0; i < size; i++) { cout << range[i] << " "; } cout << endl; return 0; } ```
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 using namespace std; void selectionSort(int arr[], int size) { for (int i = 0; i < size - 1; i++) { int minIndex = i; for (int j = i + 1; j < size; j++) { if (arr[j] < arr[minIndex]) { minIndex = j; } } // Swap values int temp = arr[i]; arr[i] = arr[minIndex]; arr[minIndex] = temp; } } int main() { int arr[] = {64, 25, 12, 22, 11}; selectionSort(arr, 5); cout << "Sorted Array (Selection Sort): "; for (int i = 0; i < 5; i++) cout << arr[i] << " "; cout << endl; return 0; } ```
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 using namespace std; void bubbleSort(int arr[], int size) { for (int i = 0; i < size - 1; i++) { for (int j = 0; j < size - i - 1; j++) { if (arr[j] > arr[j + 1]) { int temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } } int main() { int arr[] = {5, 1, 4, 2, 8}; bubbleSort(arr, 5); cout << "Sorted Array (Bubble Sort): "; for (int i = 0; i < 5; i++) cout << arr[i] << " "; cout << endl; return 0; } ```
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 using namespace std; void insertionSort(int arr[], int size) { for (int i = 1; i < size; i++) { int key = arr[i]; int j = i - 1; // Shift elements that are larger than the key while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j--; } arr[j + 1] = key; } } int main() { int arr[] = {12, 11, 13, 5, 6}; insertionSort(arr, 5); cout << "Sorted Array (Insertion Sort): "; for (int i = 0; i < 5; i++) cout << arr[i] << " "; cout << endl; return 0; } ```
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 using namespace std; void mergeSortedArrays(int A[], int sizeA, int B[], int sizeB, int C[]) { int i = 0, j = 0, k = 0; // Compare and merge elements from both arrays while (i < sizeA && j < sizeB) { if (A[i] < B[j]) { C[k++] = A[i++]; } else { C[k++] = B[j++]; } } // Append remaining elements from array A while (i < sizeA) { C[k++] = A[i++]; } // Append remaining elements from array B while (j < sizeB) { C[k++] = B[j++]; } } int main() { int A[] = {2, 5, 8, 12}; int B[] = {3, 7, 10}; int C[8]; mergeSortedArrays(A, 4, B, 3, C); cout << "Merged Array: "; for (int idx = 0; idx < 7; idx++) { cout << C[idx] << " "; } cout << endl; return 0; } ```
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 using namespace std; struct Node { int data; Node* next; }; // Function to print/traverse the linked list void traverseList(Node* head) { Node* temp = head; while (temp != NULL) { cout << temp->data << " -> "; temp = temp->next; } cout << "NULL" << endl; } int main() { // Create nodes manually Node* head = new Node(); Node* second = new Node(); Node* third = new Node(); head->data = 10; head->next = second; second->data = 20; second->next = third; third->data = 30; third->next = NULL; cout << "Linked List Path: "; traverseList(head); return 0; } ```
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 using namespace std; struct Node { int data; Node* next; }; class LinkedStack { Node* top; public: LinkedStack() { top = NULL; } void PUSH(int val) { Node* temp = new Node(); temp->data = val; temp->next = top; top = temp; cout << "Pushed " << val << " to stack." << endl; } void POP() { if (top == NULL) { cout << "Stack Underflow!" << endl; return; } Node* temp = top; cout << "Popped value: " << top->data << endl; top = top->next; delete temp; } }; int main() { LinkedStack s; s.PUSH(5); s.PUSH(10); s.POP(); s.POP(); s.POP(); return 0; } ```
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 using namespace std; struct Node { int data; Node* next; }; class LinkedQueue { Node *front, *rear; public: LinkedQueue() { front = rear = NULL; } // Addition (Enqueue) void addition(int val) { Node* temp = new Node(); temp->data = val; temp->next = NULL; if (rear == NULL) { front = rear = temp; return; } rear->next = temp; rear = temp; } // Deletion (Dequeue) void deletion() { if (front == NULL) { cout << "Queue Underflow!" << endl; return; } Node* temp = front; cout << "Removed element: " << front->data << endl; front = front->next; if (front == NULL) { rear = NULL; } delete temp; } // Display Queue void display() { Node* temp = front; cout << "Queue Content: "; while (temp != NULL) { cout << temp->data << " <- "; temp = temp->next; } cout << "NULL" << endl; } }; int main() { LinkedQueue q; q.addition(10); q.addition(20); q.display(); q.deletion(); q.display(); return 0; } ```
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.

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

Where can I download the 2026-27 CBSE printable worksheets for Class 12 Computer Science Program List?

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.

Are these Program List Computer Science worksheets based on the new competency-based education (CBE) model?

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.

Do the Class 12 Computer Science Program List worksheets have answers?

Yes, we have provided solved worksheets for Class 12 Computer Science Program List to help students verify their answers instantly.

Can I print these Program List Computer Science test sheets?

Yes, our Class 12 Computer Science test sheets are mobile-friendly PDFs and can be printed by teachers for classroom.

What is the benefit of solving chapter-wise worksheets for Computer Science Class 12 Program List?

For Program List, regular practice with our worksheets will improve question-handling speed and help students understand all technical terms and diagrams.