CBSE Class 12 Computer Science Revision Worksheet Set 03

Download Class 12 Computer Science Practice Worksheets

Review targeted academic worksheets with the CBSE Class 12 Computer Science Revision Worksheet Set 03. 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 All Chapters.

Access All Chapters Practice Papers and Solutions

View or download the dedicated CBSE Class 12 Computer Science Revision Worksheet Set 03 resource below. Engaging with these practice papers under focused study conditions ensures continuous academic progress and mastery of the 2026-27 curriculum for All Chapters.

Class_12_computer _Science_Worksheet_2

 

Q1. Write a function in C++ that counts the number of words in a long string where each word is separated by atleast one blank space and the string terminates with a period.

Q2. Write a function in C++ to find the sum of the following series:
1+2+3+4+5+6+….. upto N terms.

Q3. Write a function in C++ to find the sum of the following series:
12+32+52+72+92+….upto n terms.

Q4. Write a function in C++ to find the sum of the following series:
(1)+(1+2)+(1+2+3)+(1+2+3+4)…. Upto n terms.

Q5. Write a function in C++ to find the sum of the following series:
(22)+(22+42)+(22+42+62)+(22+42+62+82)…. Upto n terms.

Q6. Write a function in C++ to find the sum of the following series:
1/12+1/32+1/52+1/72+…upto n terms

Q7. Write a C++ function having two value parameters X and N with result type float to find the sum of series given below:
1+X1/2! + X2/3!+…..+Xn/(N+1)!

Q8. Write a program to print the truth table for XY + Z.

Q9. Write a C++ function that converts a decimal numbers between 0 to 63 into a 8‐bit binary number and prints the binary equivalent.

Q10. Write a program in C++ to print first 10 multiples of an integer N, where N is to be entered by user.

Q1. What is a parameter? Differentiate between an actual and a formal parameter with an example. Name the different types of formal parameter supported by C++. What type of parameter you must be using when passing an array to a function?

Q2. What is a compiler directive? Why do we need #include in a C++ program? Name the include file, to which following built‐in functions belong to:
(a) strcmp (b) randomize (c) setw() (d) isalnum()
(e) sin() (f) gotoxy()

Q3. Find the syntax error(s),if any, in the following program: 
include<iostream.h>
void main()
{
int R; W=90;
while w>60
{
R=W‐50;
switch(w)
{
20:cout<<”Lower Range”<<endl;
30:cout<<”Middle Range”<<endl;
20: cout<<”Higher Range”<<endl;
}
}
}

Q4. What would be output by the following program:
#include<iostream.h>
void Execute (int &B, int C=100)
{
int TEMP=B+C;
B+=TEMP;
if(C==100)
cout<<TEMP<<B<<C<<endl;
}
void main()
{
int M=90, N=10;
Execute(M);
cout<<M<<N<<endl;
Execute(M,N);
cout<<M<<N<<endl;
}

Q5. Give the output of the following program segment:
void main()
{
char *NAME = “CoMPutER”;
for(int x=0;x<strlen(NAME);x++)
if(islower(NAME[x])))
NAME[x]=toupper(NAME[x]);
else
if(isupper(NAME[x]))
if(X%2==0)
NAME[x]=tolower(NAME[x]);
else
NAME[x]=NAME[x‐1];
puts(NAME);
}

 

Question 1. Define a class TAXPAYER in C++ with following description :
Private members :
a. Name of type string
b. PanNo of type string
c. Taxabinc (Taxable income) of type float
d. TotTax of type double
e. A function CompTax( ) to calculate tax according to the following slab:
Taxable Income | Tax %
Up to 160000 | 0
>160000 and <=300000 | 5
>300000 and <=500000 | 10
>500000 | 15
Public members :
- A parameterized constructor to initialize all the members
- A function INTAX( ) to enter data for the tax payer and call function CompTax( ) to assign TotTax.
- A function OUTTAX( ) to allow user to view the content of all the data members.

Answer:
```cpp #include #include using namespace std; class TAXPAYER { string Name; string PanNo; float Taxabinc; double TotTax; void CompTax() { if (Taxabinc <= 160000) { TotTax = 0; } else if (Taxabinc > 160000 && Taxabinc <= 300000) { TotTax = (Taxabinc - 160000) * 0.05; } else if (Taxabinc > 300000 && Taxabinc <= 500000) { TotTax = (140000 * 0.05) + (Taxabinc - 300000) * 0.10; } else { TotTax = (140000 * 0.05) + (200000 * 0.10) + (Taxabinc - 500000) * 0.15; } } public: TAXPAYER(string name, string pan, float income) { Name = name; PanNo = pan; Taxabinc = income; CompTax(); } void INTAX() { cout << "Enter Name: "; getline(cin, Name); cout << "Enter PAN Number: "; cin >> PanNo; cout << "Enter Taxable Income: "; cin >> Taxabinc; CompTax(); } void OUTTAX() { cout << "Name: " << Name << endl; cout << "PAN Number: " << PanNo << endl; cout << "Taxable Income: " << Taxabinc << endl; cout << "Total Tax: " << TotTax << endl; } }; ```
In simple words: We define a class TAXPAYER that holds a taxpayer's personal details and calculates their tax amount based on dynamic slab ranges.

Exam Tip: When designing a class in C++, make sure to declare helper functions like CompTax() under the private access specifier if they are only intended for internal calculations.

 

Question 2. Give the output of the following program ( Assuming that all required header files are included in the program ) :
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void TRANSFER(char *s1,char *s2)
{ int n,j=0;
for(int i=0;*(s1+i)!='\0';i++)
{
n=*(s1+i);
if(n%2==0)
*(s2+j++)=*(s1+i);
} }
void main()
{ char *p="CharLesBabBaGe",q[80];
TRANSFER(p,q);
cout<<q<<endl;}

Answer:
The program will output the following result:
**hrLbB**

Tracing Details:
The program loops through each character in the string "CharLesBabBaGe" and checks if the ASCII value of the character is even (i.e., `n % 2 == 0`):
- 'C' (67) is Odd
- 'h' (104) is Even - Copied
- 'a' (97) is Odd
- 'r' (114) is Even - Copied
- 'L' (76) is Even - Copied
- 'e' (101) is Odd
- 's' (115) is Odd
- 'B' (66) is Even - Copied
- 'a' (97) is Odd
- 'b' (98) is Even - Copied
- 'B' (66) is Even - Copied
- 'a' (97) is Odd
- 'G' (71) is Odd
- 'e' (101) is Odd
Characters with even ASCII values are sequentially copied, resulting in "hrLbB".
In simple words: This program processes a string and copies only the characters that have an even ASCII value into a new array.

Exam Tip: When tracing string manipulation code, look up the ASCII values of individual characters carefully (uppercase and lowercase letters have different values) and keep a pointer/counter index trace.

 

Question 3. Answer the questions (i)to (iv) based on the following: 4
class FacetoFace {
char CenterCode[10];
public:
void Input( );
void Output( ); };
class Online {
char Website[50];
public:
void Sitein( );
void Siteout( );};
class Training : public FacetoFace, private Online {
long Tcode;
float Charge;
int Period;
public:
void Register( );
void Show ( ); };

Answer:
(i) **Multiple Inheritance** is shown in the above example, as class `Training` inherits from more than one base class (`FacetoFace` and `Online`).

(ii) Member functions accessible from `Show()` function of class `Training`:
- From `Training`: `Register()`, `Show()`
- From `FacetoFace`: `Input()`, `Output()`
- From `Online`: `Sitein()`, `Siteout()`

(iii) Members accessible through an object of class `Training`:
- Only public member functions can be accessed: `Register()`, `Show()`, `Input()`, `Output()`.

(iv) **No**, the function `Output()` is not accessible inside the function `Siteout()`.
*Justification:* `Output()` is a member of the class `FacetoFace` and `Siteout()` is a member of the class `Online`. Since there is no inheritance relationship between `FacetoFace` and `Online`, they cannot access each other's members.
In simple words: We analyze a multi-level class hierarchy to identify inheritance types, accessible member functions, and variable visibility boundaries.

Exam Tip: In multiple inheritance, public base class member functions are accessible via the derived class object, while private base class functions are completely hidden outside.

 

Question 4. Write a function TRANSFER( int ALL[ ], int N) , to transfer all the prime numbers from a one dimensional array ALL[ ] to another one dimensional array PRIME[ ]. The resultant array PRIME[ ] must be displayed on screen.
Answer:
```cpp #include using namespace std; bool isPrime(int num) { if (num <= 1) return false; for (int i = 2; i * i <= num; i++) { if (num % i == 0) return false; } return true; } void TRANSFER(int ALL[], int N) { int PRIME[100]; // Assuming maximum size of 100 for destination array int count = 0; for (int i = 0; i < N; i++) { if (isPrime(ALL[i])) { PRIME[count++] = ALL[i]; } } cout << "Prime numbers in the array: "; for (int i = 0; i < count; i++) { cout << PRIME[i] << " "; } cout << endl; } ```
In simple words: This function scans an input array, identifies all prime numbers using a helper test, and copies them into a second array.

Exam Tip: Always implement a robust prime checking logic (usually testing divisors from 2 up to the square root of the number) to ensure correct filtering.

 

Question 5. An array PP[40][32] is stored in the memory along the row with each of the elements occupying 10 bytes. Find out the memory location for the element PP[18][22], if the element PP[7][10] is stored at memory location 5000.
Answer:
Since the array is stored along the row, we use the Row-Major formula (assuming 0-based indexing):
$$\text{Address}(PP[i][j]) = \text{Base Address} + W \times [ i \times C + j ]$$
Where:
- Number of columns ($C$) = 32
- Element size ($W$) = 10 bytes
- $\text{Address}(PP[7][10]) = 5000$

Step 1: Calculate Base Address $$5000 = \text{Base Address} + 10 \times [ 7 \times 32 + 10 ]$$ $$5000 = \text{Base Address} + 10 \times [ 224 + 10 ]$$ $$5000 = \text{Base Address} + 10 \times [ 234 ]$$ $$5000 = \text{Base Address} + 2340$$ $$\text{Base Address} = 5000 - 2340 = 2660$$
Step 2: Find Address of $PP[18][22]$ $$\text{Address}(PP[18][22]) = 2660 + 10 \times [ 18 \times 32 + 22 ]$$ $$\text{Address}(PP[18][22]) = 2660 + 10 \times [ 576 + 22 ]$$ $$\text{Address}(PP[18][22]) = 2660 + 10 \times [ 598 ]$$ $$\text{Address}(PP[18][22]) = 2660 + 5980 = 8640$$
In simple words: We use the row-major memory mapping formula to find the base memory address of the 2D array and then locate another specific element's address.

Exam Tip: In row-major formula, remember to multiply the row index by the number of columns ($C = 32$) and scale by the element size ($W = 10$ bytes).

 

Question 6. Convert the following infix expression to its equivalent postfix expression Showing stack contents for the conversion:
(A+B)*(C^(D-E)+F)-G

Answer:
Let us trace the conversion step-by-step using an operator stack:

Element ScannedStack StatusPostfix Expression
(( 
A(A
+( +A
B( +AB
)(empty)AB+
**AB+
(* (AB+
C* (AB+C
^* ( ^AB+C
(* ( ^ (AB+C
D* ( ^ (AB+CD
-* ( ^ ( -AB+CD
E* ( ^ ( -AB+CDE
)* ( ^AB+CDE-
+* ( +AB+CDE-^
F* ( +AB+CDE-^F
)*AB+CDE-^F+
--AB+CDE-^F+*
G-AB+CDE-^F+*G
(end)(empty)AB+CDE-^F+*G-

The equivalent postfix expression is: **AB+CDE-^F+*G-**
In simple words: We convert an arithmetic infix expression into its postfix equivalent by utilizing an operator stack to maintain operator precedence.

 

Exam Tip: The exponential operator ^ has the highest precedence; ensure it is popped off the stack when an operator of lower precedence (like + or -) is encountered.

 

Question 7. Assume a text file “coordinate.txt” is already created. Using this file create a C++ function to count the number of words having first character capital .Also count the presence of a word ‘Do’.
Answer:
```cpp #include #include #include #include using namespace std; void countWords() { ifstream fin("coordinate.txt"); if (!fin) { cout << "Error opening file.\n"; return; } string word; int capitalCount = 0; int doCount = 0; while (fin >> word) { // Count words starting with a capital letter if (isupper(word[0])) { capitalCount++; } // Count instances of the exact word "Do" if (word == "Do") { doCount++; } } cout << "Number of words starting with a capital letter: " << capitalCount << endl; cout << "Occurrences of the word 'Do': " << doCount << endl; fin.close(); } ```
In simple words: This program opens a text file, reads it word-by-word, and counts how many words start with a capital letter or match the exact word "Do".

Exam Tip: Utilize the standard input file stream ifstream and check characters using the isupper() function for cleaner, faster code.

 

Question 8. Write function in C++ to perform Insert operation in a dynamically allocated Queue containing names of employees
Answer:
```cpp #include #include using namespace std; struct NODE { char Name[50]; NODE *Link; }; void InsertQueue(NODE *&front, NODE *&rear, char empName[]) { NODE *temp = new NODE; if (temp == NULL) { cout << "Queue Overflow! Out of memory.\n"; return; } strcpy(temp->Name, empName); temp->Link = NULL; if (rear == NULL) { front = rear = temp; } else { rear->Link = temp; rear = temp; } } ```
In simple words: We create a dynamically allocated queue (using a linked list) and add new employee names at the rear end of the queue.

Exam Tip: Remember to set the next pointer (Link) of the newly created node to NULL to properly mark the new end of the dynamic queue.

 

Question 9. Write a function in C++ to display object from the binary file “PRODUCT.Dat” whose product priceis more than Rs 200. Assuming that binary file is containing the objects of the following class:
class PRODUCT {
int PRODUCT_no;
char PRODUCT_name[20];
float PRODUCT_price;
public:
void enter( ) {
cin>> PRODUCT_no ; gets(PRODUCT_name) ;
cin >> PRODUCT_price; }
void display() {
cout<< PRODUCT_no ; cout<<PRODUCT_name ;cout<< PRODUCT_price; }
int ret_Price( ) {
return PRODUCT_price;
} };

Answer:
```cpp #include #include using namespace std; void displayHighPriceProducts() { ifstream file("PRODUCT.Dat", ios::binary); if (!file) { cout << "Error opening binary file.\n"; return; } PRODUCT obj; while (file.read((char*)&obj, sizeof(obj))) { if (obj.ret_Price() > 200) { obj.display(); cout << endl; } } file.close(); } ```
In simple words: This function reads a binary file containing PRODUCT records and prints the details of any product whose price exceeds Rs 200.

Exam Tip: Always use file.read((char*)&obj, sizeof(obj)) within a loop to read binary objects safely until the end of the file is reached.

 

Question 10. Write a function Get1from2() function in C++ to transfer the content from two arrays First[ ] and Second[ ] to array All[ ]. The even places (0,2,4…..) of array All[] should get the contents from the array First[ ] and odd places (1,3,5….)of the array All[ ] should get the contents from the array Second[ ]
Eg:
If the First [ ] array contains 30, 60,90,
And the Second [ ] array contains 10, 50,80,
Then All [ ] array should contain 30, 10, 60,50,90,80.

Answer:
```cpp void Get1from2(int First[], int Second[], int All[], int N) { for (int i = 0; i < N; i++) { All[2 * i] = First[i]; // Transfers elements to even indexes All[2 * i + 1] = Second[i]; // Transfers elements to odd indexes } } ```
In simple words: This function takes two arrays of equal size and merges them into a single target array by alternating their elements.

Exam Tip: For any index i in the source arrays, the formula 2i and 2i+1 perfectly places the elements at even and odd indexes of the destination array.

Free CBSE Practice Worksheets: Class 12 Computer Science All Chapters

Download Chapter Worksheets: Class 12 Computer Science

Access structured practice worksheets for All Chapters aligned with the 2026 CBSE curriculum. These downloadable exercises for Class 12 Computer Science help students build accuracy and reinforce core concepts for upcoming school tests.

Concept Clarification for All Chapters

Each worksheet draws directly from authorized standard textbooks to maintain academic accuracy. Evaluating your finished exercises against expert-verified solutions helps master the formal presentation standards expected in school evaluations.

Effective Revision Strategies for School Exams

Consistent engagement with these exercises builds familiarity with recurring exam themes. If specific areas within All Chapters cause trouble, utilize our dedicated NCERT solutions for Class 12 Computer Science to clear up doubts immediately.

FAQs

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

You can download the latest chapter-wise printable worksheets for Class 12 Computer Science All Chapters for free from StudiesToday.com. These have been made as per the latest CBSE curriculum for this academic year.

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

Yes, Class 12 Computer Science worksheets for All Chapters 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 All Chapters worksheets have answers?

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

Can I print these All Chapters 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 All Chapters?

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