CBSE Class 12 Computer Science Programming in C++ Two Marks HOTs

Refer to CBSE Class 12 Computer Science Programming in C++ Two Marks HOTs. We have provided exhaustive High Order Thinking Skills (HOTS) questions and answers for Class 12 Computer Science Programming in C++. Designed for the 2025-26 exam session, these expert-curated analytical questions help students master important concepts and stay aligned with the latest CBSE, NCERT, and KVS curriculum.

Programming in C++ Class 12 Computer Science HOTS with Solutions

Practicing Class 12 Computer Science HOTS Questions is important for scoring high in Computer Science. Use the detailed answers provided below to improve your problem-solving speed and Class 12 exam readiness.

HOTS Questions and Answers for Class 12 Computer Science Programming in C++

<p></p>2 Marks Questions
Programming in C++

1. What is wrong with the following while loop:
a. int counter = 1; b. int counter = 1;
while ( counter < 100) while ( counter < 100)
{ cout << counter << “\n;
cout << counter << “\n; counter + +;
counter - -;
}

2. What will be the output of following:
void main ( )
{
int val = 10;
cout << val ++ << val << ++ val;
}

3. Given the following code fragment:
int ch = 20;
cout << ch << ++ ch << ch << “\n”;
(i) The output of the code fragment.
(ii) What is the effect of replacing ++ ch with ch + 1?

4. Differentiate between the output of following code fragments:
(i) int f = 1, i = 2; (ii) int f = 1, i = 2;
while (++ i < 5) do {
f *= i; f *= i;
cout << f; } while (++ i < 5);
cout<<f;

5. Give output:
#include<iostream.h>
int global = 20;
void fun (int &x, int y)
{
x = x – y; y = x * 10;
cout << x << ‘, ’ << y << ‘\n’;
}
void main()
{
int global = 8;
fun (:: global, global);
cout << global << ‘, ’ << :: global << ‘\n’;
fun (global, :: global);
cout << global << ‘, ’ << :: global << ‘\n’;
}

6. Give output:
#include<iostream.h>
int fun ( int &a, int b = 0)
{
if (a % b = = 0) return ++ a;
else return b - - ;
}
void main()
{
int x = 20, y = 23;
y = fun (x, y);
cout << x << ‘, ’ << y << ‘\n’;
x = fun (y);
cout << x << ‘, ’ << y << ‘\n’;
y = fun (x);
cout << x << ‘, ’ << y << ‘\n’;
}

7. Find output
#include<iostream.h>
void fun (int &A, int &B)
{
A = A + B;
B = A – B;
A = A – B;
}
void main ( )
{
int a = 4, b = 18;
fun (a, b);
cout << a << “, ” << b;
}

8. Give output:
void Change (int x[4]. int i)
{
x[i] = x[i] * I;
}
void main ( )
{
int x[ ] = {11, 21, 31, 41};
for (int i = 0; i < 4; i++)
{
Change (x, i);
cout << x[i] << ‘\n’;
}
}

9. Rewrite the following codes after removing errors, if any, in the following snippet. Explain each
error.
#include<iostream.h>
void main()
{
int x[5], *y, z[5]
for (i = 0; i < 5; i ++
{
x[i] = i;
z[i] = i + 3;
y = z;
x = y;
}
}

10. Rewrite the following codes after removing errors, if any, in the following snippet. Explain each error.
void main()
{
const int i = 20;
const int * const ptr = &i;
(*ptr)++;
int j = 15;
ptr = &j;
}

11. Give the output of the following program:
void main()
{
char *p = “Difficult”;
char c;
c = ++ *p ++;
printf (“%c”,c);
}

12. Give the output of the following program:
void main()
{
int x [] = { 10, 20, 30, 40, 50}:
int *p, **q, *t;
p = x;
t = x + 1;
q = &t;
cout << *p << “,” << **q << “,” << *t++;
}

13. In the following program, if the value of N given by the user is 20, what maximum and minimum value the program could possibly display ()?
#include<iostream.h>
#include<stdlib.h>
void main()
{
int N, Guessme;
randomize();
cin>>N;
Guessme = random(N-10) + 10 ;
cout<<Guessme<<endl;
}

14. Rewrite the following program after removing the error(s), if any. Underline each correction.
#include <iostream.h>
void main()
{
int x, sum =0;
cin>>n;
for (x=1;x<100, x+=2)
if x%2=0
sum+=x;
cout<< “sum=” >>sum;
}

15. What will be the output of the following program?
#include <iostream.h>
void main()
{
int A[5] ={0, 3, 4, 2, 1};
int b[5]= {0};
int n =4;

for ( int i=0; i<5;++i)
b[a[i]]=a[i];
cout<< b[0]<<b[1]<<b[2]<<b[3}<<b[4];
}

16. What will be the output of the following program
#include<iostream.h>
void main()
{
int var1=5,var2=10;
for(int i=1;i<=2;i++)
{
cout << var1++ << “\t” << --var2<< endl;
cout << var2-- << “\t” << ++var1<< endl;
}
}

17. Find the output of the following program
#include<iostream.h>
void main( )
{
long NUM = 1234543;
int F = 0, S = 0;
do
{
int Rem = NUM% 10;
if (Rem % 2 !=0)
F+ =R;
else
S+ = R;
NUM/=10;
} while(NUM>0);
cout<<F-S;
}

18. Find the output of the following program:
#include<iostream.h>
void main()
{
long Number = 7583241;
int First=0, Second=0;
do
{
int R=Number%10;
if (R%2==0)
First+=R;
else
Second+=R;
Number /=10;
} while (Number > 0);
cout<<First-Second;
}

19. Rewrite the following program after removing the syntactical error(s), if any Underline each
correction:
#include <iostream.h>
void main( )
{
struct TV
{
char Manu_name[20];
char Tv_Type;
int Price = 17000;
} New Tv;
gets(Manu_name);
gets(Tv_Type);
}

20. Identify error in the following program segment:
class ABC{
public:
int read();
char display val();
private:
int x;
char ch;
}

21. Write the output of the following program:
#include<iostream.h>
class Test{
int a, b;
public:
void set( int I, int j) { a = I; b = j;}
void show() {cout << a << “ ” << b << endl;}
};
void main()
{
Test t1, t2;
T1.set(10,4);
t2 = t1;
t1.show()
t2.show()
}

22. Answer the questions after going through the following class
class Exam
{ int year;
public:
Exam(int y) {year=y;} //Constructor 1
Exam(Exam & t); //Constructor 2
};
i. Create an object, such that it invokes Constructor I.
ii. Write complete definition for Constructor 2.

23. Answer the questions after going through the following class.
class Exam
{
char Subject[20] ;
int Marks ;
public :
Exam() // Function 1
{
strcpy(Subject, “Computer” ) ;
Marks = 0 ;
}
Exam(char P[ ]) // Function 2
{
strcpy(Subject, P) ;
Marks=0 ;
}
Exam(int M) // Function 3
{
strcpy(Subject, “Computer”) ;
Marks = M ;
}
Exam(char P[ ], int M) // Function 4
{
strcpy(Subject, P) ;
Marks = M ;
}
};
a) Which feature of the Object Oriented Programming is demonstrated using Function 1, Function2, Function 3 and Function 4 in the above class Exam?
b) Write statements in C++ that would execute Function 3 and Function 4 of class Exam.

24. Rewrite the following program after removing all the syntax error(s), if any. Underline each
correction.
#include<iostream.h>
struct Pixels
{
int Color, Style ;
}
void ShowPoint(Pixels P)
{
cout<<P.Color,P.Style<<endl;
}
void main()
{
Pixels Point1 = (5,3);
ShowPoint(Point 1);
Pixels Point2 = Point1
Color.Point1+=2;
ShowPoint(Point2);
}

25. Write a function in C++ to count the number of uppercase alphabets present in a text file “STORY.TXT”.

26. Write a function in C++ to count the number of lowercase alphabets present in a text file“STORY.TXT”.

27. Write a function in C++ to count the number of alphabets present in a text file “XY.TXT”.

28. Write a user defined function in C++ to read the content of a text file “JOKE.TXT”, count and display the number of blank spaces present in it.

29. Write a function in C++ to count and display the number of lines starting with alphabet ‘A’ in a text file “MYFILE.TXT”.

30. Write a function in C++ to print the count of the word “and” in the text file “Myfile.txt”.

31. Write a function in C++ to write the characters entered through the keyboard into the file “myfile.txt”, until a ‘#’ character is entered.

32. Write a function in C++ to count the number of words present in the text file “MyFile.txt”.
Assume that each word is separated by a blank space and no blank space appears in the beginning and at the end of the file.

33. Write a function in C++ to count and display the number of student records stored in the binary file “Student,dat” . Assume that student is a structure and 10 bytes of memory is required to store each student record.

34. How many stream objects would you need to manage the following situations:
(a) To process three files sequentially.
(b) To merge two sorted files into third file.

35. Observe the program segment carefully and answer the question that follows:
class item
{
int item_no;
char item_name[20];
public:
void enterDetail( );
void showDetail( );
int getItem_no( ){ return item_no;}
};
void modify(item x )
{
fstream File;
File.open( “item.dat”, ios::binary|ios::in|ios::out ) ;
item i;
while(File .read((char*) & i , sizeof (i)))
{
if(x . getItem_no( ) = = i . getItem_no( ))
{
File.seekp(File.tellg( ) – sizeof(i));
File.write((char*) &x , sizeof (x));
}
}
File.close( ) ; //Statement 1
}
The function modify( ) modifies a record in the file “ item.dat “ .State whether statement 1 is mandatory? Give explanation.

36. Write a function in C++ to calculate the average word size in the text file “MyFile.txt”.

37. Given the binary file STUDENT.DAT , containing the records of the following class:
class student
{
int roll_no;
char name[20];
float percent;
public:
void getData( );
void show( );
float returnPercent( )
{
return percent;
}
};
Write a function BELOW75( ) in C++ , that would count and display the records of those students whose score is below 75 percent.

38. Write a function which takes pointers to two strings as parameter and compare these strings. The function should return 1 if two strings are same otherwise return 0.

39. Give the output of the following program( Assume all necessary header files are included)
:
void main( )
{
char * x = “teAmIndia”;
char c;
c = ++ *x ++;
cout<<c;
}

40. Give the output of the following program(Assume all necessary header files are included)
:
void main( )
{
char *x = “teAmIndia”;
char c;
c = ( *(x+1) ) ++ ;
cout<<c;
}

41. Give the output of the following program( Assume all necessary header files are included)
:
void main( )
{
char * x = “teAmIndia”;
char c;
c = ++( *(x+1) );
cout<<c;
}

42. What will be the output of the program( Assume all necessary header files are included) :
#include<iostream.h>
void print (char * p )
{
p = "pass";
cout<<"value is "<<p<<endl;
}
void main( )
{
char * x = "Best of luck";
print(x);
cout<<"new value is "<<x<<endl;
}

Data Structure: Array, Stack and Queue

Convert the following infix expressions to postfix expressions

1. (((x*y –a*b)-d/f)+a)*b

2. (a+(((b-(c*d-e)+f))/g))*(h-j)

3. A+B*(P+Q)^C/D

4. A+B-C*D+F-G

5. A^B-A/(B*(A-B-A*D)/B)

6. A+(((B-C)*(D-E)+F/G)^(H-J)

7. (A+B) *(C^(D-E)+F-G

8. A*(B+(C+D)*(E+F)/G)*H

9. A*(B+C)/D-E-(F+G/H)

10. A + B * C ^ D – (E / F – G)

11 A – B + C * D ^ E * G / H

12 ((A+B)-((C_D)*E/F)*G

13 (TRUE && FALSE) || ! (FALSE || TRUE)

14 (A + B * C ) / D + E / (F * G + H / I)

15 NOT A OR NOT B AND NOT C
Evaluate the following postfix expression E given below, show the contents of the stack during the evaluation

16 E= 10,*,15,-,25,5,/,2+

17 E= 7,6,2,^,*,18,+
E= 5,9,+2,*,4,1,1,3,_,*,-

18 E= 120,45,20,+,25,15,-,+,*

19 TRUE FALSE TRUE FALSE NOT OR TRUE OR AND

20 E= 30,5,2,^,12,6,/,+,-

21 15, 3, 2, +, /, 7, + 2, *

22 25, 8, 3, - , / 6, *, 10 +

23 AB – CD + E * + WHERE A = 5, B = 3, C = 5, D = 4 AND E = 2

24 7,6, +, 8, * , 2, -, 3, * , 2, 4, * , -

25 8, 7, +, 9, 8, +, -, 2, / , 3,4, * 2, / +

26 E= 5,20,15,-,*,25,2,*,+

27 IF A=2,C=3,D=2,E=5,F=4,G=6
EFG^D*AC/- +

Boolean Algebra

2 Minimize F(A,B,C) = A’BC+AB’C’+AB’C+AB+A’B’ using Karnaugh Map

3 Minimize the 4 variable Boolean function
F(A,B,C,D)= ABC’D+A’BCD+A’B’C+A’B’D’+AC’+A’B’C+B’

4 Draw the circuit for the following function using NAND Gate
F(A,B,C,D)=D(A+B(C+A’)+B’)

5 Design (A+B).(C+D) using NOR Gate.

6 Simplify the following Boolean Expression using Boolean postulates and laws of Boolean Algebra.
(a) E=xyz + x’y+xyz’
(b) Z=(a’+a).b’.c+a.b’.c’+a.b.(c+c’)

7 Simplify the following Boolean Expression using Boolean postulates and laws of Boolean Algebra.
X= a’.b’.c’+a’.b’.c+a.b’.c’+a.b’.c

8 Simplify the following Boolean Expression using Boolean postulates and laws of Boolean Algebra.
F = (A+B’+C+D’).(A’+B’+C+D).(A+B’+C+D’).(A’+B’+C+D’).(A’+B+C+D’)

9 Prove x’.y’+y.z = x.y’.z’+x’.y’.z+x’.y.z+x.y.z algebraically.

10 A Boolean function F defined on three input variable X,Y,Z is 1 if and only if the number of 1(One) input is odd (e.g. F is 1 if X=1,Y=0,Z=0). Draw the truth table for the above function and express it in canonical sum of product form.

11 Draw the logic circuit diagram of the following expression using NOR Gate only P =
(x’+y’+z’)(x+y’+z)(x+y+z’).

12 Check the validity of the following Boolean Expression:
(y+z)(z+x)=(x’+y’)(x’+z’)(y’+z’)

13 Prove that (a’+b’)(a’+b)(a+b’)=a’b’.

14 Simplify AB+(AC)’+AB’C(AB+C) algebraically.

15 Convert (A+B)(AB’+AC)(A’C’+B’C’) to SOP form.

16 Convert (A+B)(B’+C)(A’+C) to SOP Form.

17 Prove XY+YZ+Y’Z=XY+Z algebraically.

18 Draw the Truth Table for XOR and XNOR Gate.

19 Prove that NAND and NOR Gate are universal gate.

20 Explain the Relation ship between minterms and maxterms. An Expression is given in SOP form F(x,y,z)=S(0,1,4,5) show its min terms and maxterms.

21 Represent (A’+B’+C’)(A+B’+C’) in NOR to NOR logic network.

22 Draw the simplified logic diagram using only NAND gates to implement the three input function f denoted by the expression (Not By using K Map) F= ∑( 0,1,2,5)

23 Express P+Q’R in canonical SOP Form and POS Form.

24 Express the Boolean Function F(x,y,z) =xy+x’z in a product of max term form.

25 Write the equivalent canonical Sum of Product expression for the following Product of Sum Expression F(X,Y,Z)= π (1,3,6,7)

26 A majority gate is a digital circuit whose output is equal to 1 if the majority of the inputs are 1.
The output is 0 otherwise. By means of a truth table, find the Boolean expression implemented by 3 input majority gates.

27 An even parity gate is a digital circuit whose output is equal to 1 if the odd numbers of inputs are 1. The output is 0 otherwise. By means of a truth table
(a) Find the Boolean function implemented by a 3 input odd parity gate.
(b) Which single gate can be used to represent this circuit

3 Marks Questions

Programming in C++

1 Give output of following code fragment:
int val, res, n = 1000;
cin >> val;
res = n + val > 1750 ? 400 : 200;
cout << res;
(a) if the input is 2000.
(b) if the input is 1000.
(c) if the input is 500.

2 What will be the output if input is:
(i) a (ii) c (iii) d (iv) h (v) b
char ch, out [10] = “ ”;
cin >> ch;
switch (ch) {
case ‘a’: strcat(out, “a”);
case ‘b’: strcat(out, “b”);
case ‘c’: strcat(out, “c”);
break;
case ‘d’: strcat(out, “d”);
break;
default : strcat(out, “Not abcd”);

HOTS for Programming in C++ Computer Science Class 12

Students can now practice Higher Order Thinking Skills (HOTS) questions for Programming in C++ to prepare for their upcoming school exams. This study material follows the latest syllabus for Class 12 Computer Science released by CBSE. These solved questions will help you to understand about each topic and also answer difficult questions in your Computer Science test.

NCERT Based Analytical Questions for Programming in C++

Our expert teachers have created these Computer Science HOTS by referring to the official NCERT book for Class 12. These solved exercises are great for students who want to become experts in all important topics of the chapter. After attempting these challenging questions should also check their work with our teacher prepared solutions. For a complete understanding, you can also refer to our NCERT solutions for Class 12 Computer Science available on our website.

Master Computer Science for Better Marks

Regular practice of Class 12 HOTS will give you a stronger understanding of all concepts and also help you get more marks in your exams. We have also provided a variety of MCQ questions within these sets to help you easily cover all parts of the chapter. After solving these you should try our online Computer Science MCQ Test to check your speed. All the study resources on studiestoday.com are free and updated for the current academic year.

Where can I download latest CBSE HOTS for Class 12 Computer Science Programming in C++

You can download the CBSE HOTS for Class 12 Computer Science Programming in C++ for latest session from StudiesToday.com

Are the Class 12 Computer Science Programming in C++ HOTS available for the latest session

Yes, the HOTS issued by CBSE for Class 12 Computer Science Programming in C++ have been made available here for latest academic session

What does HOTS stand for in Class 12 Computer Science Programming in C++

HOTS stands for "Higher Order Thinking Skills" in Programming in C++ Class 12 Computer Science. It refers to questions that require critical thinking, analysis, and application of knowledge

How can I improve my HOTS in Class 12 Computer Science Programming in C++

Regular revision of HOTS given on studiestoday for Class 12 subject Computer Science Programming in C++ can help you to score better marks in exams

Are HOTS questions important for Programming in C++ Class 12 Computer Science exams

Yes, HOTS questions are important for Programming in C++ Class 12 Computer Science exams as it helps to assess your ability to think critically, apply concepts, and display understanding of the subject.