CBSE Class 12 Informatics Practices File Handling Worksheet

Read and download free pdf of CBSE Class 12 Informatics Practices File Handling Worksheet. Students and teachers of Class 12 Informatics Practices can get free printable Worksheets for Class 12 Informatics Practices File Handling in PDF format prepared as per the latest syllabus and examination pattern in your schools. Class 12 students should practice questions and answers given here for Informatics Practices in Class 12 which will help them to improve your knowledge of all important chapters and its topics. Students should also download free pdf of Class 12 Informatics Practices Worksheets prepared by teachers as per the latest Informatics Practices books and syllabus issued this academic year and solve important problems with solutions on daily basis to get more score in school exams and tests

Worksheet for Class 12 Informatics Practices File Handling

Class 12 Informatics Practices students should refer to the following printable worksheet in Pdf for File Handling in Class 12. This test paper with questions and answers for Class 12 will be very useful for exams and help you to score good marks

Class 12 Informatics Practices Worksheet for File Handling

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

Q2. Write a function to count and print the number of complete words as “to” and “are” stored in a text file “ESSAY.TXT”.

Q3. Write a function in C++ to display lines starting with alphabet ‘A’ or alphabet ‘E’ present in a text file “LINES.TXT”.

TYPE 3 Question :Function write type questions Based on binary files

Q1. Given a binary file “BUS.DAT”, containing records of the following class bus type.
class bus
{ int bus_no;
char desc[40];
int distance; //in km
public:
void read( )
{ cin>>bus_no; gets(desc) ; cin>>distance; }
void display( )
{ cout<<bus_no; puts(desc); cout<<distance; }
int retdist( )
{ return distance; }
};
Write a function in C++ that would read the contents of file “BUS.DAT” and display the details of those buses which travels the distance more than 100 km.

Q2. Given a binary file Sports.dat, containing records of the following structure type:
Struct Sports
{
Char Event[20];
Char Participant[10][30];
};
Write a function in C++ that would read contents from the file Sports .dat and creates a file named Athletic.dat copying only those records from Sports.dat where the event name is “Athletics”.

Q3. Given a binary file TELEPHON.DAT, containing records of the following class Directory :
class Directory
{
char Name [20] ;
char Address [30] ;
char AreaCode[5] ;
char Phone_No[15] ;
public :
void Register ( ) ;
void Show ( ) ;
int CheckCode (char AC [ ] )
{
return strcmp ( AreaCode , AC ) ;
}
};
Write a function COPYABC ( ) in C++ , that would copy all those records having AreaCode as “123” from TELEPHON.DAT to TELEBACK.DAT.

Q4. Write a function in C++ to display object from the binary file “PRODUCT.Dat” whose product price is 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;
}
};

Q5. Given the binary file CAR.Dat, containing records of the following class CAR type:
class CAR
{
int C_No;
char C_Name[20];
float Milage;
public:
void enter( )
{
cin>> C_No ; gets(C_Name) ; cin >> Milage;
}
void display( )
{
cout<< C_No ; cout<<C_Name ; cout<< Milage;
}
int RETURN_Milage( )
{
return Milage;
}
};
Write a function in C++, that would read contents from the file CAR.DAT and display the details of car with mileage between 100 to 150.

Q6. Write a function in C++ to search for a BookNo from a binary file “BOOK.DAT”, assuming the binary file is containing the objects of the following class.
class BOOK
{
int Bno;
char Title[20];
public:
int RBno(){return Bno;}
void Enter(){cin>>Bno;gets(Title);}
void Display(){cout<<Bno<<Title<<endl;}
};

Q7. Write a function in C++ to add new objects at the bottom of a binary file “STUDENT.DAT”, assuming the binary file is containing the objects of the following class.
class STUD
{
int Rno;
char Name[20];
public:
void Enter(){cin>>Rno;gets(Name);}
void Display(){cout<<Rno<<Name<<endl;}
};
void Addnew()
{
fstream FIL;
FIL.open(“STUDENT.DAT”,ios::binary|ios::app);
STUD S;
char CH;
do
{
S.Enter();
FIL.write((char*)&S,sizeof(S));
cout<<”More(Y/N)?”;cin>>CH;
}
while(CH!=’Y’);
FIL.close();
}

Q8. Write a function in C++ to search and display the details of all flights, whose destination is “Mumbai” from “FLIGHT.DAT”. Assuming the binary file is
containing objects of class.
class FLIGHT
{
int Fno; //Flight Number
char From[20] ; //Flight Starting point
char To[20] ; //Flight Destination
public :
char* GetFrom( ) {return From ;}
char* GetTo( ) {return To ;}
void Enter( ) {cin >> Fno ; gets (From) ;gets(To) ; }
void Display( ) { cout << Fno<< “:” << From << “:” << To << endl ;}
};

Q9. Given a binary file GAME.DAT, containing records of the following structure type
struct Game
{
char GameName [20];
char Participant [10] [30];
};
Write a function in C++ that would read contents from the file GAME.DAT and creates a file named BASKET.DAT copying only those records from GAME.DAT where the game name is “Basket Ball”.

Q10. Assuming the class Computer as follows :
class computer
{
char chiptype[10];
int speed;
public:
void getdetails()
{
gets(chiptype);
cin>>speed;
}
void showdetails()
{
cout<<“Chip”<<chiptype<<“ Speed= “<<speed;
}
};
Write a function readfile( ) to read all the records present in an already existing binary file SHIP.DAT and display them on the screen, also count the number of records present in the file.

TYPE 1 QUESTION : ( Statement write type questions )

Q1. 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();
}

Q2. 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
int Bytes = ______________________ //Statement 2
int Count = Bytes / sizeof(Item);
File.close();
return Count;
}

Q3. Write the command to place the file pointer at the 10th and 4th record starting position using seekp() or seekg() command. File object is ‘file’ and record name is ‘STUDENT’.

Q4. Observe the program segment given below carefully and fill in the blanks marked as Statement 1 and Statement 2 using tellg ( ) and skeep ( ) functions for performing the required task.
#include <fstream. h>
class c1ient
{
long Cno ; char Name [20], Email [30] ;
public :
//Function to allow user to enter the cno,Nme , Email
void Enter ( ) ;
// Function to allow user to enter (modify) Email
void modify ( ) ;
long ReturnCno( ) { return Cno ; }
} ;
void changeEmail ( )
{ Client C ;
fstream F ;
F. open (“INFO.DAT” , ios :: binary |ios :: in|ios :: out) ;
long Cnoc ; //Client’s no. whose Email needs to be changed
cin >> Cnoc ;
while (F. read (( char*) &C, sizeof (C)))
{
if (Cnoc = = C.Returncno( ))
{
C.Modify( ) ;
//Statement 1
int Pos = __________//To find the current position of
//file pointer
//statement 2
_________________ //To move the file pointer to write
//the modified record back into the
//file for the desired cnoc
F.write ((char*) &C, sizeof(C));
}
}
F.close( ) ;
}

Q5. Observe the program segment given below carefully, and answer the question that follows:
class PracFile
{
intPracno;
char PracName[20];
int TimeTaken;
int Marks;
public:
// function to enter PracFile details
void EnterPrac( );
// function to display PracFile details
void ShowPrac( ):
// function to return TimeTaken
int RTime() {return TimeTaken;}
// function to assign Marks
void Assignmarks (int M)
{ Marks = M;}
};
void AllocateMarks( )
{ fstream File;
File.open(“MARKS.DAT”,ios::binary|ios::in|ios::out);
PracFile P;
int Record = 0;
while (File.read(( char*) &P, sizeof(P)))
{
if(P.RTime()>50)
P.Assignmarks(0)
else
P.Assignmarks(10)
______________ //statement 1
______________ //statement 2
Record + + ;
}
File.close();
}
If the function AllocateMarks () is supposed to Allocate Marks for the records
in the file MARKS.DAT based on their value of the member TimeTaken.
Write C++ statements for the statement 1 and statement 2, where,
statement 1 is required to position the file write pointer to an appropriate place
in the file and statement 2 is to perform the write operation with the modified
record.

Q6. Observe the program segment given below carefully, and answer the question that follows:
class Book
{
int Book no;
char Book_name[20];
public:
//function to enter Book details
void enterdetails();
// function to display Book details
void showdetails();
//function to return Book_no
int Rbook_no (){return Book_no;}
} ;
void Modify(Book NEW)
{
fstream File;
File.open(“BOOK.DAT”,ios::binary|ios::in|ios::out);
Book OB;
int Recordsread = 0, Found = 0;
while (!Found && File.read((char*)&OB, sizeof (OB)))
{
Recordsread ++ ;
if (NEW.RBook_no() = = OB.RBook_no))
{
______________ //Missing Statement
File.write((char*)&NEW, sizeof (NEW));
Found = 1;
}
else
File.write((char*)&OB, sizeof(OB));
}
if (! Found)
cout<<" Record for modification does not exist”;
File.close();
}
If the function Modify( ) is supposed to modify a record in file BOOK.DAT with the
values of Book NEW passed to its argument, write the appropriate statement for
Missing Statement using seekp( ) or seekg( ), whichever needed, in the above code
that would write the modified record at its proper place.

Q7. Observer the program segment carefully and fill in the blanks marked as statement 1& 2
#include<fstream.h>
class MATERIAL
{
int Mno;char Mname[25]; int qty;
public:
:
void ModifyQty();
};
void MATERAIL::ModifyQty()
{
Fstream File;
Fil.open("MATERIAL.DAT",ios::binary|ios::in|ios::out);
int Mpno;
cout<<"Materail no to modify Qty :"; cin>>Mpno;
while(Fil.read((char*)this,sizeof(MATERIAL)))
{
if(Mpno==Mno)
{
cout<<"Present Qty :" <<qty<,endl;
cout<"Changed Qty :"; cin>>qty;
int Position=_________________; //(Statement 1)
___________________________: //(Statement 2)
Fil.write((char * this,sizeof (MATERIAL)); // Re-writing the record
}
}
Fil.close();
}

Q8. Observe the program segment given below carefully, and answer the question that follows
class Candidate
{
long CId ; //Candidate’s Id
char CName[20]; // Candidate’s Name
float Marks; //Candidate’s Marks
public :
void Enter( ) ;
void Display( ) ;
void MarksChange ( ); // Function to change marks
long R_CId( ) { return CId ; }
};
void MarksUpdate ( long ID)
{ fstream File ;
File.open (“ CANDIDATE.DAT”, ios : : binary | ios : : in | ios : : out ) ;
Candidate C ;
int Record = 0 , Found = 0;
while ( ! Found && File . read ( ( char *) & C , sizeof ( C) ) )
if ( Id == C.R_CId ( ) )
{ cout << “ Enter new marks” ;
C. MarkChange ( );
_________________ // Statement 1
_________________ // Statement 2
Found = 1 ;
}
Record ++ ;
}i
f ( found == 1 ) cout << “ Record Updated “ ;
File. close ( );
}
Write the Statement 1 to position the File pointer at the beginning of the Record for which the
candidate’s Id matches with the argument passed, and Statement 2 to write the updated Record at that
position.

Q9. Observe the program segment given below carefully and fill the blanks marked in statement 1 using seekg( ) or seekp( ) functions for performing the required task.
#include<fstream.h>
class FILE
{ int Num;
char Name[30];
public:
void GO_Record(int); }; //function to read Nth record from the file
void FILE::GO_Record(int N)
{
FILE Rec;
Fstream File;
File.open(“STOCK”,ios::binary|ios::in);
______________________________ //statement 1
File.read((char*)&Rec,sizeof(Rec));
cout<<Rec.Num<<Rec.Name<<endl;
File.close( );
}

Q10. Observe the program segment carefully and answer the question that follows:
class stock
{
int Ino, Qty; Char Item[20];
public:
void Enter() { cin>>Ino; gets(Item); cin>>Qty;}
void issue(int Q) { Qty+=0;}
void Purchase(int Q) {Qty-=Q;}
int GetIno() { return Ino;}
};
void PurchaseItem(int Pino, int PQty)
{ fstream File;
File.open(“stock.dat”, ios::binary|ios::in|ios::out);
Stock s;
int success=0;
while(success= = 0 && File.read((char *)&s,sizeof(s)))
{
If(Pino= = ss.GetIno())
{
s.Purchase(PQty);
_______________________ // statement 1
_______________________ // statement 2
Success++;
}
}
if (success = =1)
cout<< “Purchase Updated”<<endl;
else
cout<< “Wrong Item No”<<endl;
File.close() ;
}

TOPIC : File Handling

TYPE 2 QUESTION : Function write type questions

Q1. 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’.

Example:

Do less Thinking and pay more attention to your heart. Do Less Acquiring and pay more Attention to what you already have. Do Less Complaining and pay more Attention to giving. Do Less criticizing and pay more Attention to Complementing. Do less talking and pay more attention to SILENCE.

Output will be :

Total words with capital vowel - 16

Count of ‘Do’ in file – 5

Q2. Write a function in C++ to print the count of the word as an independent word in a text file story.txt Eg: There was a tiger in the zoo. The tiger was very naughty.
The output of the program should be 2.

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

Q4. Write a function to count and print the number of complete words as “to” and “are” stored in a text file “ESSAY.TXT”.
void CWORDS( )
{
ifstream fin(“ESSAY.TXT”);
char st[80];
int count=0;
while(!fin.eof())
{
      fin>>st;
      if(!fin)
      break;
      if(strcmpi(st,”to”) = =0 || strcmpi(st,”are”)= =0)
      count++;
}
cout<<”\nTotal ‘to’ & ‘are’ words = “<<count;
fin.close( );
}

Q5. Write a function in C++ to read the content of a text file “News.TXT” and display all those lines which are either starting with ‘S’ or starting with ‘W’.

Q6. Write a function in C++ to count the number of lines present in a text file “STORY.TXT”.

Q7. Write a function in C++ to count and display the no of three letter words in the file “VOWEL.TXT”.
Example:
If the file contains:
A boy is playing there. I love to eat pizza. A plane is in the sky.
Then the output should be: 4

Q8. Write a function in C++ to count the words “this” and “these” present in a text file “ARTICLE.TXT”.
[Note that the words “this” and “these” are complete words]

Q9. Write a function 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

Q10. Assuming that a text file named FIRST.TXT contains some text written into it, write a function named vowelwords( ), that reads the file FIRST.TXT and creates a new file named SECOND.TXT, to contain only those words from the file FIRST.TXT which start with a lowercase vowel (i.e. with ‘a’, ‘e’, ‘i’, ‘o’, ‘u’). For example if the file FIRST.TXT contains
Carry umbrella and overcoat when it rains
Then the file SECOND.TXT shall contain umbrella and overcoat it

More Worksheets for Class 12 Informatics Practices
CBSE Class 12 Informatics Practices Commonly Used Libraries Worksheet
CBSE Class 12 Informatics Practices Computer Networking Worksheet
CBSE Class 12 Informatics Practices Computer Xml Extensible Markup Language Worksheet
CBSE Class 12 Informatics Practices Concept Of Inheritance Worksheet
CBSE Class 12 Informatics Practices Database Connectivity To MySQL Worksheet
CBSE Class 12 Informatics Practices Database Fundamentals MySQL Revision Tour Worksheet
CBSE Class 12 Informatics Practices Database Transactions Worksheet
CBSE Class 12 Informatics Practices File Handling Worksheet
CBSE Class 12 Informatics Practices Html Basic Html Elements Worksheet
CBSE Class 12 Informatics Practices Html Lists Tables And Forms Worksheet
CBSE Class 12 Informatics Practices Introducing Classes And Objects Worksheet
CBSE Class 12 Informatics Practices It Applications Worksheet
CBSE Class 12 Informatics Practices Java Application Worksheet
CBSE Class 12 Informatics Practices Java Gui Programming Revision Worksheet
CBSE Class 12 Informatics Practices Java Gui Programming Worksheet
CBSE Class 12 Informatics Practices More On Sql Grouping Records And Table Joins Worksheet
CBSE Class 12 Informatics Practices MySQL Worksheet
CBSE Class 12 Informatics Practices Networking Worksheet
CBSE Class 12 Informatics Practices Open Source Concepts Worksheet
CBSE Class 12 Informatics Practices Sure Shot Questions Worksheet
CBSE Class 12 Informatics Practices Sure Shot Questions Worksheet Set A
CBSE Class 12 Informatics Practices Table And Integrity Constraints Worksheet
CBSE Class 12 Informatics Practices Web Application Development Worksheet

Worksheet for CBSE Informatics Practices Class 12 File Handling

We hope students liked the above worksheet for File Handling designed as per the latest syllabus for Class 12 Informatics Practices released by CBSE. Students of Class 12 should download in Pdf format and practice the questions and solutions given in the above worksheet for Class 12 Informatics Practices on a daily basis. All the latest worksheets with answers have been developed for Informatics Practices by referring to the most important and regularly asked topics that the students should learn and practice to get better scores in their class tests and examinations. Expert teachers of studiestoday have referred to the NCERT book for Class 12 Informatics Practices to develop the Informatics Practices Class 12 worksheet. After solving the questions given in the worksheet which have been developed as per the latest course books also refer to the NCERT solutions for Class 12 Informatics Practices designed by our teachers. We have also provided a lot of MCQ questions for Class 12 Informatics Practices in the worksheet so that you can solve questions relating to all topics given in each chapter.

Where can I download latest CBSE Printable worksheets for Class 12 Informatics Practices File Handling

You can download the CBSE Printable worksheets for Class 12 Informatics Practices File Handling for latest session from StudiesToday.com

Is there any charge for the Printable worksheets for Class 12 Informatics Practices File Handling

There is no charge for the Printable worksheets for Class 12 CBSE Informatics Practices File Handling you can download everything free

Are there any websites that offer free test sheets for Class 12 Informatics Practices File Handling

Yes, studiestoday.com provides all latest NCERT File Handling Class 12 Informatics Practices test sheets with answers based on the latest books for the current academic session

What topics are covered in CBSE Class 12 Informatics Practices File Handling worksheets?

CBSE Class 12 Informatics Practices File Handling worksheets cover all topics as per the latest syllabus for current academic year.

How can I use worksheets to improve my Class 12 Informatics Practices scores?

Regular practice with Class 12 Informatics Practices worksheets can help you understand all concepts better, you can identify weak areas, and improve your speed and accuracy.