Topic Wise Solved Problems Question – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
CPP: Topicwise Exam Question: handling-text-files siteicon
04A 3

Aditi has used a text editing software to type some text. After saving the article as WORDS.TXT , she realised that she has wrongly typed alphabet J in place of alphabet I everywhere in the article.
Write a function definition for JTOI() in C++ that would display the corrected version of entire content of the file WORDS.TXT with all the alphabets “J” to be displayed as an alphabet “I” on screen .
Note: Assuming that WORD.TXT does not contain any J alphabet otherwise.
Example: If Aditi has stored the following content in the file WORDS.TXT :

WELL, THJS JS A WORD BY JTSELF. YOU COULD STRETCH THJS TO BE A SENTENCE

The function JTOI() should display the following content:

WELL, THIS IS A WORD BY ITSELF. YOU COULD STRETCH THIS TO BE A SENTENCE

CBSE12D-2017

Finding 4 character words in a text file 2

Write function definition for WORD4CHAR() in C++ to read the content of a text file FUN.TXT, and display all those words, which has four characters in it.
Example: If the content of the file fun.TXT is as follows:

When I was a small child, I used to play in the garden with my grand mom. Those days were amazingly funful and I remember all the moments of that time

The function WORD4CHAR() should display the following:

When used play with days were that time
CBSE12D-2016

04A 2

Write function definition for SUCCESS () in C++ to read the content of a text file STORY.TXT count the presence of world STORY and display the number of occurrence of this word.
Note :
-The word STORY should be an independent word
-Ignore type cases (i.e. lower/upper case)
Example: If the content of the file Story.TXT is as follows:

Success shows others that we can do it. 
It is possible to achieve success with hard work. Lot of money does not mean SUCCESS.

The function SUCCESS () should display the following:

3
CBSE12D-2015

04A 3

A text file named MATTER.TXT contains some text, which needs to be displayed such that every next character is separated by a symbol ‘#’. Write a function definition for HashDisplay () in C++ that would display the entire content of the file MATTER.TXT in the desired format.
Example:
If the file MATTER.TXT has the following content stored in it:
THE WORLD IS ROUND
The function HashDisplay () should display the following content:
T#H#E# #W#O#R#L#D# #I#S# #R#O#U#N#D#

CBSE12A-2018

04A 3

Polina Raj has used a text editing software to type some text in an article. After saving the article as MYNOTES.TXT , she realised that she has wrongly typed alphabet K in place of alphabet C everywhere in the article. Write a function definition for PURETEXT() in C++ that would display the corrected version of the entire article of the file MYNOTES.TXT with all the alphabets “K” to be displayed as an alphabet “C” on screen .
Note: Assuming that MYNOTES.TXT does not contain any C alphabet otherwise.
Example:
If Polina has stored the following content in the file MYNOTES.TXT :

I OWN A KUTE LITTLE KAR.
I KARE FOR IT AS MY KHILD.

The function PURETEXT() should display the following content:

I OWN A CUTE LITTLE CAR.
I CARE FOR IT AS MY CHILD.
CBSE12A-2017

04A 2

Write function definition for DISP3CHAR() in C++ to read the content of a text file KIDINME.TXT, and display all those words, which have three characters in it.
Example: If the content of the file KIDINME.TXT is as follows:

When I was a small child, I used to play in the garden with my grand mom. 
Those days were amazingly funful and I remember all the moments of that time

The function DISP3CHAR() should display the following:

was the mom and all the
CBSE12A-2016

04A-2015 2

Write function definition for TOWER() in C++ to read the content of a text file WRITEUP.TXT, count the presence of word TOWER and display the number of occurrences of this word.
Note :
‐ The word TOWER should be an independent word
‐ Ignore type cases (i.e. lower/upper case)
Example: If the content of the file WRITEUP.TXT is as follows:

Tower of hanoi is an interesting problem.
Mobile phone tower is away from here. Views
from EIFFEL TOWER are amazing.

The function TOWER () should display the following:

3
CBSE12A-2015