Official Class 12 Computer Science Revision Material: CBSE Class 12 Computer Science Data File Handling In C++ Notes
Review targeted revision notes for Class 12 Computer Science with the CBSE Class 12 Computer Science Data File Handling In C++ Notes. Built according to official educational guidelines for the 2026-27 academic year, these downloadable summaries for Data File Handling In C++ support daily study and last-minute exam readiness.
Chapter-wise Concept Summaries: Data File Handling In C++
Access the complete concept summary PDF for Data File Handling In C++ below. Regular review of these targeted notes builds familiarity with complex Class 12 Computer Science themes and helps secure higher marks in final school evaluations.
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 and Revision Notes for Class 12 Computer Science Data File Handling In C++
Quick Revision Notes: Data File Handling In C++ (CBSE)
Explore reliable chapter overviews for Data File Handling In C++ tailored for Class 12 learners. Use these structured points to grasp difficult themes and ensure solid preparation for upcoming assessments.
Expert Study Material for Class 12 Computer Science
Built using the official NCERT book for Class 12 Computer Science, these notes provide reliable academic guidance. Pair your summary review with our recommended NCERT solutions to master optimal problem-solving approaches.
Complete Your Chapter Revision
Explore our broader library of printable assignments, chapter notes, and mock tests designed to support continuous revision and secure higher marks in CBSE assessments.
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.