CBSE Class 12 Computer Science HOTs Programming in C++ One mark Questions

Refer to CBSE Class 12 Computer Science HOTs Programming in C++ One mark Questions. 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>
Q.1 Mark Questions
Programming in C++
1. 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, int y )
{
fstream File;
File.open( “item.dat”, ios::binary | ios::in | ios::out) ;
item i;
int recordsRead = 0, found = 0;
while(!found && File.read((char*) &i , sizeof (i)))
{
recordsRead++;
if(i . getItem_no( ) = = y )
{
_________________________//Missing statement
File.write((char*) &x , sizeof (x));
found = 1;
}
}
if(! found)
cout<<”Record for modification does not exist” ;
File.close() ;
}
If the function modify( ) is supposed to modify a record in the file “ item.dat “,
which item_no is y, with the values of item x passed as argument, write the
appropriate statement for the missing statement using seekp( ) or seekg( ),
whichever is needed, in the above code that would write the modified record at its
proper place.

Ans.1.
Using seekp()
File.seekp(Record * sizeof(i)); //object name
OR
File.seekp(Record * sizeof(item)); // class name
OR
File.seekp(File.tellg() - sizeof(i));
OR
File.seekp(File.tellg() - sizeof(item));
OR
File.seekp(-sizeof(i), ios::cur);
Using seekg()
OR
File.seekg(Record * sizeof(i));
OR )
File.seekg(Record * sizeof(item));
OR
File.seekg(-sizeof(i), ios::cur);

Q. 2 Observe the program segment carefully and answer the question that follows:
class member
{
int member_no;
char member_name[20];
public:
void enterDetail( );
void showDetail( );
int getMember_no( ){ return member_no;}
};
void update(member NEW )
{
fstream File;
File.open( “member.dat”, ios::binary|ios::in|ios::out) ;
member i;
while(File .read((char*) & i , sizeof (i)))
{
if(NEW . getMember_no( ) = = i . getMember_no( ))
{
_________________________//Missing statement
File.write((char*) &NEW , sizeof (NEW));
}
}
File.close() ;
}
If the function update( ) is supposed to modify the member_name field of a record in the file “ member.dat” with the values of member NEW passed as argument, write the appropriate statement for the missing statement using seekp( ) or seekg( ), whichever is needed, in the above code that would write the modified record at its proper place.

Ans 2. Same as previous question. Just change the class name or object name.

Q.3. Observe the program segment carefully and answer the question that follows:
class item
{
int item_no;
char item_name[20];
public:
void enterDetails( );
void showDetail( );
int getItem_no( ){ return item_no;}
};
void modify(item x )
{
fstream File;
File.open( “item.dat”, _______________ ) ; //parameter missing
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));
}
else
File.write((char*) &i , sizeof (i));
}
File.close() ;
}
If the function modify( ) modifies a record in the file “ item.dat “ with the values of item x passed as argument, write the appropriate parameter for the missing parameter in the above code, so as to modify record at its proper place.

Ans3. You have to complete the syntax of file opening.
File.open( “item.dat”, ios::binary|ios::in|ios::out ) ;

Q.4. Observe the program segment carefully and answer the question that follows:
class member
{
int member_no;
char member_name[20];
public:
void enterDetails( );
void showDetail( );
int getMember_no( ){ return member_no;}
};
void update(member NEW )
{
fstream File;
File.open( “member.dat”, ios::binary|ios::in|ios::out) ;
member i;
while(File .read((char*) & i , sizeof (i)))
{
if(NEW . getMember_no( ) = = i . getMember_no( ))
{
File.seekp( _________ , ios::cur ) //Paremeter Missing
File.write((char*) &NEW , sizeof (NEW));
}
}
File.close() ;
}
If the function update( ) is supposed to modify a record in the file “ member.dat” with the values of member NEW passed as argument, write the appropriate parameter for the missing parameter in the above code, so as to modify record at its proper place.

Ans 4. File.seekp( -sizeof(i), ios::cur );

Q.5. Observe the program segment given below carefully, and answer the question that follows:
class Applicant
{
long AId; //Applicant’s Id
char Name[20]; //Applicant’s Name
float Score; //Applicant’s Score
public:
void Enroll();
void Disp();
void MarksScore(); //Function to change Score
long R_Aid() {return Aid;}
};
void ScoreUpdate(long Id)
{
fstream File;
File.open(“APPLI.DAT”,ios::binary|ios::in|ios::out);
Applicant A;
int Record=0,Found=0;
while (!Found&&File.read((char*)&C, sizeof(c)))
{
if (Id==A.R_Aid())
{
cout<<”Enter new Score…”;
cin>>A.MarksScore();
_________________ //statement 1
_________________ //statement 2
Found = 1;
}
Record++;
}
if(Found==1) cout<<”Record Updated”;
File.close();
}
Write the Statement1 to position the File Pointer at the beginning of the Record for which the Applicant’s Id matches with the argument passed, and Statement2 to write the updated Record at that position.

Ans 5. Statement 1:
File.seekp(Record * sizeof(A)); //object name
OR
File.seekp(Record * sizeof(Applicant)); // class name
File.seekp(File.tellg() - sizeof(A));
OR
File.seekp(File.tellg() - sizeof(Applicant));
OR
File.seekp(-sizeof(A), ios::cur);
File.seekg(Record * sizeof(A));
OR
File.seekg(Record * sizeof(Applicant));
OR
File.seekg(-sizeof(A), ios::cur);
Statement 2:
File.write((char*)&A, sizeof(A));
OR
File.write((char*)&A, sizeof(Applicant));

Q.6. Observe the program segment carefully and answer the question that follows:
class student
{
int student_no;
char student_name[20];
int mark;
public:
void enterDetail( );
void showDetail( );
void change_mark( ); //Function to change the mark
int getStudent_no( ){ return student_no;}
};
void modify( int y )
{
fstream File;
File.open( “student.dat”, ios::binary|ios::in|ios::out) ;
student i;
int recordsRead = 0, found = 0;
while(!found && File .read((char*) & i , sizeof (i)))
{
recordsRead++;
if(i . getStudent_no( ) = = y )
{
i . change_mark( );
_________________________//Missing statement 1
_________________________//Missing statement 2
found = 1;
}
}
if( found = = 1)
cout<<”Record modified” ;
File.close() ;
}
If the function modify( ) is supposed to change the mark of a student having student_no y in the file “student.dat”, write the missing statements to modify the student record.

Ans 6. Same as previous question. In this question it is not defined explicitly that the function of statement1 and statement2 but here first we have to move file pointer at the appropriate place ( statement1) and the write the record on that location(statement2) Write any one of statement1 and statement 2 from Q.5.

Q.7. 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)))//Statement 1
{
if(x . getItem_no( ) = = i . getItem_no( ))
{
File.seekp(File.tellg( ) – sizeof(i));
File.write((char*) &x , sizeof (x));
}
}
File.close() ;
}
If the function modify( ) modifies a record in the file “ item.dat” with the values of item x passed as argument, rewrite statement 1 in the above code using eof( ) ,so as to modify record at its proper place.

Ans.7. while(!File.eof ( )) ;{
(File .read((char*) & i , sizeof (i));

Q.8. Observe the program segment given below carefully and fill the blanks marked as Statement 1 and Statement 2 using seekp() and seekg() functions for performing the required task.
#include <fstream.h>
class Item
{
int Ino;char Item[20];
public:
//Function to search and display the content from a particular record number
void Search(int );
//Function to modify the content of a particular record number
void Modify(int);
};
void Item::Search(int RecNo)
{
fstream File;
File.open("STOCK.DAT",ios::binary| ios::in);
______________________ //Statement 1
File.read((char*)this,sizeof(Item));
cout<<Ino<<"==>"<<Item<<endl;
File.close();
}
void Item::Modify(int RecNo)
{
fstream File;
File.open("STOCK.DAT",ios::binary|ios::in|ios::out);
cout>>Ino;
cin.getline(Item,20);
______________________ //Statement 2
File.write((char*)this,sizeof(Item));
File.close();
}

Ans.8. File.seekg(RecNo*sizeof(Item)); //Statement 1
File.seekp(RecNo*sizeof(Item)); //Statement 2

Q.9. Observe the program segment given below carefully and fill the blanks marked as Statement 1 and Statement 2 using seekg() and tellg() functions for performing the required task.
#include <fstream.h>
class Employee
{
int Eno;char Ename[20];
public:
//Function to count the total number of records
int Countrec();
};
int Item::Countrec()
{
fstream File;
File.open("EMP.DAT",ios::binary|ios::in);
______________________ //Statement 1- To take the file pointer to
//the end of file.
int Bytes =
______________________ //Statement 2-To return total number of
bytes from the beginning of
file to the file pointer.
int Count = Bytes / sizeof(Item);
File.close();
return Count;
}

Ans.9. File.seekg(0,ios::end); //Statement 1
File.tellg(); //Statement 2

Q.10. Observe the program segment given below carefully and fill the blanks marked as
Statement 1 and Statement 2 using seekg() and tellg() functions for performing
the required task.
class Library
{
long Ano;
char Title[20];
int Qty;
public:
void Enter(int);
void Display();
void Buy(int Tqty)
{
Qty+=Tqty;
}
long GetAno( ) { return Ano;}
};
void BuyBook(long BAno. Int BQty)
{
Fstream File;
File.open(“STOCK>DAT”,ios::binary|ios::in|ios::out);
int Position=-1;
Library L;
while(Position==-1&&File.read((char*)&L, sizrof(L))
{
If(L.GetAno()==BAno)
{
L.Buy(BQty);
Position=File.teeg()-sizeof(L);
//Line1: To place the file pointer to the required position
__________________________________;
//Line2: To write the object L on to the binary file
___________________________________;
}
If(position==-1)
cout<<”No updation done as required Ano not found”;
File.close()’
}

Ans.10. Line1:
File.seekp(Position);
OR
File.seekp(-sizeof(L), ios::cur);
OR
File.seekg(-sizeof(L), ios::cur);
OR
File.seekg(Position);
Line2:
File.write((char*)&L, sizeof(L));
OR
File.write((char*)&L, sizeof(Library));

Q.11. A file named as “STUDENT.DAT” contains the student records, i.e. objects of class student.Write the command to open the file to update a student record. (Use suitable stream class and file mode(s).

Ans.11. fstream inof(“STUDENT.DAT”,ios::in|ios::out|ios::binary)
or
fstream inof;
inof.open(“STUDENT.DAT”,ios::in|ios::out|ios::binary)

Q.12. A file named as “EMPLOYEE.DAT” contains the employee records, i.e. objects of class employee.Assuming that the file is just opened through the object FILE of fstream class, in the required file mode, write the command to position the put pointer to point to fifth record from the last record.

Ans.12. File.seekp(-5,ios::end);

Q.13. A file named as “EMPLOYEE.DAT” contains the student records, i.e. objects of class employee. Assuming that the file is just opened through the object FILE of fstream class, in the required File mode, write the command to position the get pointer to point to eighth record from the beginning.

Ans.13. File.seekg(8,ios::beg);

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.