Here is the CBSE Class 12 Computer Science Data File Handling In C++ Notes for your studies. Use these Class 12 Computer Science revision notes, created by professional educators for the 2026-27 academic term. They make difficult ideas very easy to understand and focus on core definitions, helping Class 12 students prepare quickly before exams.
Revision Notes for Class 12 Computer Science Data File Handling In C++
Use these Class 12 Computer Science Data File Handling In C++ notes for rapid revision before your exams. Designed specifically for school tests and final evaluations, these summaries break down complex sections so you can understand everything clearly.
Get Data File Handling In C++ Notes PDF for Class 12 Computer Science
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.
Ans.1. File.seekp((recordsRead-1)*sizeof(x),ios::beg); or File.seekp(-1*sizeof(x),ios::cur);
General program structure used for operating a Text File
2 Marks Questions
Text files in input mode:
Write a function in a C++ to count the number of lowercase alphabets present in a text file “BOOK.txt”.
int countalpha()
{ ifstream Fin(“BOOK.txt”);
char ch;
int count=0;
while(!Fin.eof())
{Fin.get(ch);
if (islower(ch))
count++;
}
Fin.close();
return count;
}
Function to calculate the average word size of a text file.
void calculate()
{ fstream File;
File.open(“book.txt”,ios::in);
char a[20];
char ch;
int i=0,sum=0,n=0;
while(File)
{ File.get(ch);
a[i]=ch;
i++;
if((ch==’ ‘) || ch(== ‘.’)||(char==’,’)(ch==’\t’)||(ch==’\n’)
{i --; sum=sum +i;
i=0; N++;
}
}
cout<<”average word size is “<<(sum/n);
}
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.
int countword()
{ ifstream Fin(“BOOK.txt”);
char ch[25];
int count=0;
while(!Fin.eof())
{Fin>>ch;
if (isupper(ch[0]))
count++;
}
Fin.close();
return count;
}
Function to count number of lines from a text files (a line can have maximum 70 characters or ends at ‘.’)
int countword()
{ ifstream Fin(“BOOK.txt”);
char ch[70];
int count=0;
if (!Fin)
{ cout<<”Error opening file!” ;
exit(0);
}
while(1)
{Fin.getline(ch,70,‘.’);
if (Fin.eof())
break;
count++;
}
Fin.close();
return count;
}
A program to display the size of a file in bytes.
#include<iostream.h>
#include<fstream.h>
#include<process.h>
#include<conio.h>
int main()
{
char filename[13];
clrscr();
cout<”Enter Filename:\n”;
cin.getline(filename,13);
ifstream infile(filename);
if(!infile)
{cout>>”sorry ! Can not open “<<filename <<”file\n”;
exit(-1);
}
long no_bytes=0;
char ch;
infile.seekg(0,ios::end);
no_bytes=infile.tellg();
cout<<”File Size is”<<no_bytes<<”bytes\n”;
return 0;
}
Text files in output mode:
C++ program, which initializes a string variable to the content “There is an island of opportunity in the middle of every difficulty.” and output the string one character at a time to the disk file “OUT.TXT”.
#include<fstream.h>
int main()
{ ofstream fout(“OUT.TXT”);
char *str = ”There is an island of opportunity in the middle of every difficulty.” ;
int i=0;
if(!fout)
{
cout<<”File cannot be opened “;
return 0;
}
while (str[i]!=’\0’)
{fout<<str[i];
i++;
}f
out.close();
}
Exercise: (2 Marks Questions)
1. te a function in a C++ to count the number of uppercase alphabets present in a text file “BOOK.txt”
2. Write a function in a C++ to count the number of alphabets present in a text file “BOOK.txt”
3. Write a function in a C++ to count the number of digits present in a text file “BOOK.txt”
4. Write a function in a C++ to count the number of white spaces present in a text file “BOOK.txt”
5. Write a function in a C++ to count the number of vowels present in a text file “BOOK.txt”
6. Write a function in a C++ to count the average word size in a text file “BOOK.txt”
7. Write a function in C++ to print the count of the word “the” as an independent word in a text file
STORY.TXT.
For example, if the content of the file STORY.TXT is
There was a monkey in the zoo.
The monkey was very naughty.
Then the output of the program should be 2.
8. Assume a text file “Test.txt” is already created. Using this file, write a function to create three
files “LOWER.TXT” which contains all the lowercase vowels and “UPPER.TXT” which contains
all the uppercase vowels and “DIGIT.TXT” which contains all digits.
9. Create a function FileLowerShow() in c++ which take file name(text files)as a argument and display its all data into lower case
10. Write a function in C++ to count the number of lines present in a text file “Story.txt”.
HOTS FILE HANDLING
1. Write a function in a C++ to count the number of consonants present in a text file “Try.txt”
2. Write a function in a C++ to count the number of uppercase vowels present in a text file “Novel.txt”
3. Write a function in a C++ to display the sum of digits present in a text file “Fees.txt”.
4. Write a function in a C++ to display the product of digits present in a text file “Number.txt”.
5. Write a function in a C++ to find the largest digit present in a text file “Marks.txt”
3 Marks Questions
General program structure used for operating a Binary File
Program to read and write a structure using read() and write() using binary file.
struct student
{
char name[15];
float percent;
};
void main()
{
clrscr();
student s;
strcpy(s.name,”rasha”);
s.percent=89.50;
ofstream fout;
fout.open(“saving”, ios::out | ios:: binary);
if(!fout)
Please click the link below to download pdf file for CBSE Class 12 Computer Science - Data File Handling In C++.
Free study material for Computer Science
Study Material & Revision Notes for Class 12 Computer Science Data File Handling In C++
Download Chapter Notes: Class 12 Computer Science Data File Handling In C++
Students can use these Revision Notes for Data File Handling In C++ to quickly understand all the main concepts. This study material has been prepared as per the latest CBSE syllabus for Class 12. Our teachers always suggest that Class 12 students read these notes regularly as they are focused on the most important topics that usually appear in school tests and final exams.
Core Chapter Summary & Practice Sets for Data File Handling In C++
Crafted around the standard NCERT book for Class 12 Computer Science, these notes reinforce core learning. Once you finish reading the chapter summary, read our expert NCERT solutions for Class 12 to evaluate your grasp of the material and strengthen your core base in Computer Science.
Master Class 12 Computer Science with Extra Practice Sets
Enhance your academic standing by completing the MCQ questions and practice worksheets offered alongside. These solved checks confirm your command of Data File Handling In C++ ideas. All website learning assets are free of charge, structured around latest Computer Science patterns. Reading these revision notes daily cultivates deep test assurance.
FAQs
You can download the teacher prepared revision notes for CBSE Class 12 Computer Science Data File Handling In C++ Notes from StudiesToday.com. These notes are designed as per 2026-27 academic session to help Class 12 students get the best study material for Computer Science.
Yes, our CBSE Class 12 Computer Science Data File Handling In C++ Notes include 50% competency-based questions with focus on core logic, keyword definitions, and the practical application of Computer Science principles which is important for getting more marks in 2026 CBSE exams.
Yes, our CBSE Class 12 Computer Science Data File Handling In C++ Notes provide a detailed, topic wise breakdown of the chapter. Fundamental definitions, complex numerical formulas and all topics of CBSE syllabus in Class 12 is covered.
These notes for Computer Science are organized into bullet points and easy-to-read charts. By using CBSE Class 12 Computer Science Data File Handling In C++ Notes, Class 12 students fast revise formulas, key definitions before the exams.
No, all study resources on StudiesToday, including CBSE Class 12 Computer Science Data File Handling In C++ Notes, are available for immediate free download. Class 12 Computer Science study material is available in PDF and can be downloaded on mobile.