Login


Lost your password?

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


Shop
CPP All : Handling Text Files


Exam Papers Problems

04A #5681

( As In Exam - CBSE12A-2016 )

Write function definition for DISP3CHAR() in C++ to read the content of a tex

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

04A #5722

( As In Exam - CBSE12A-2018 )

A text file named MATTER.TXT contains some text, which needs to be displayedÂ

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#

04A #5783

( As In Exam - CBSE12A-2017 )

Polina Raj has used a text editing software to type some text in an article.

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.

04A #5890

( As In Exam - CBSE12D-2015 )

Write function definition for SUCCESS () in C++ to read the content of a text

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

04A-2015 #5973

( As In Exam - CBSE12A-2015 )

Write function definition for TOWER() in C++ to read the content of a text fi

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

04A #6047

( As In Exam - CBSE12D-2017 )

Aditi has used a text editing software to type some text. After saving the ar

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

Finding 4 character words in a text file #6179

( As In Exam - CBSE12D-2016 )

Write function definition for WORD4CHAR() in C++ to read the content of a tex

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
Solved Problems

Count alphabets in a file #5026

Write a program to count alphabets in a given file “NOTES.TXT”. 

Write a program to count alphabets in a given file “NOTES.TXT”. What would be  the output when this file is tested with the NOTES.TXT  file containing the following lines.

This is first line
This is second line
This is third line

Count Words in a Text File #5034

Write a function to count and return the number of words present in the filen

Write a function to count and return the number of words present in the filename passed to it as an argument. Assume that each word is separated by a single space and their is no space in the
beginning and end of the file.

Also demonstrate the use of this function in the main routine assuming a file NOTES.TXT that contains the following text.

This is first line
This is second line
This is third line

Count Spaces in a Text File #5036

Write a function to count and return the number of space characters present i

Write a function to count and return the number of space characters present in the filename passed to it as an argument. Also show implementation of this function in the main routine using NOTES.TXT file that contain the following data

This is first line
This is second line
This is third line

Displaying and counting lines starting with a certain character #5039

Write a program to display the lines starting with character ‘A’

Write a program to display the lines starting with character ‘A’ or ‘a’ in the file “PROG.TXT” that contains following text. Also display the count of such lines.

A programmer should always be hardworking.
For that matter everyone should be hardworking.
A programmer is always under pressure.
Yes! not everyone is always under pressure.

Displaying three character words in a file #5044

Write a program to display all the words in a file that are three character w

Write a program to display all the words in a file that are three character words. Assume that filename is
MATTER.TXT and it contains the following matter.

The quick brown fox jumps over a lazy dog

Required header files in a file handling program #5046

Raju is trying to run the following program in his compiler, but he is unable

Raju is trying to run the following program in his compiler, but he is unable to do the some due to absence of some header files he forgot to include. Please help him.

int main()
{
ifstream ipfile("LIST.TXT",ios::in);
char ch;
while(!ipfile.eof())
{
ipfile.get(ch);
if(isdigit(ch)) cout<<ch<<" ";
} 
ipfile.close(); 
return 0;
}

Exam Paper Problems:7  Solved Problems:6 
×
Introductory Sessions Beginning to Program Tokens Keyword and Identifiers Data Types Variables and Constants Operators Simple User Input Building Expressions and Formulas Simple Real World Problems Simple If and If Else Multiple-Nested-Ladder of If Else Switch case selection Simple Loops Tricks in Loops - break continue scope Loop Applications - Handling numerals Series printing loops Nested Loops Pattern printing loops Number Varieties and Crunches String Handling (Null Terminated) Strings - string class type Functions (Built-in) Functions - user defined Functions Reference Passing/Returning Arrays Concepts and 1-D Arrays Array Data Management Two dimensional arrays and Matrices Structures Basics Structures passing/returning Display Using IO Manipulation Display Using C Formatting Tricks User Defined Data Types Enumerated Types Preprocessor Directives And Macros Exception Handling Programming Paradigms and OOPs Advantages Abstraction and Encapsulation Polymorphism Inheritance Function Overloading Concepts Function Overloading Varieties Function Overloading Special Cases Defining Classes Creating and Using Class Objects Class Members Accessibility Class Function Types Inline Functions Constant Functions Nesting of Functions Class Members Scope Resolution Static Members in a Class Array of Objects Constructor Concepts Default Constructor Parameterized Constructor Copy Constructor Constructor Overloading Destructors Inheritance Fundamentals Public Derivations Private and Protected Derivations Multiple Inheritance Mult-Level Inheritance Class Nesting Data File Concepts Handling Text Files Handling Binary Files Pointer Concepts Pointer and Arrays Pointers and Functions Object Pointers This Pointer Linked Lists Stacks Queues


Back