2 Marks Questions

 

  1. What role is played by file modes in file operations? Describe the various file mode constants and their meanings.
Read more

 

  1. What are the advantages of saving data in:

    (i) binary form (ii) text form

Read more

 

  1. Write a program that counts the number of characters up to the first $ in input and that leaves the $ in the input stream.

Read more

 

  1. Write a program that reads a text file and creates another file that is identical expect that every sequence of

consecutive blank space is replaced by a single space.

Read more

 

  1. Suggest the situation where write() and read() are preferred over get() and put() for file I/O operations. Support

your answer with examples.

Read more

 

  1. Discuss the working of good() and bad() functions in file I/O error handling.
Read more

 

  1. What are the similarities and differences between bad() and fail() functions.

Read more  

 

  1. How is the working of file I/O error handling functions associated with error-status flags?

Read more  

 

  1. Write a user defined function in C++ to read the content from a text file NOTES.TXT, count and display the number of blank spaces present in it.

 

Read more

 

  1. Write a function in C++ to print the count of the word 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.

Read more
  1. Write a function in C++ to count the number of uppercase alphabets present in a text file “ARTICLE.TXT”.               Read more
  1. Write a function in C++ to count the number of digits present in a text file “PARA.TXT”.
Read more

 

  1. Write a function in C++ to print the count of the word is an independent word in a text file DIALOGUE.TXT.

For example, if the content of the file DIALOGUE.TXT is:

This is his book. Is this good?

Then the output of the program should be 2.

Read more

 

  1. A file contains a list of telephone numbers in the following form:

Arvind 7258031

Sachin 7259197

Karma 5119812

The names contain only one word the names and telephone numbers are separated by white spaces. Write

program to read a file and display its contents in two columns.

Read more

 

  1. 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.

Read more

 

  1. Given a binary file STUDENT.DAT, containing records of the following class Student type

class Student

Read more

 

  1. Write a function in C++, that would read contents of file STUDENT.DAT and display the details of those Students whose Percentage is above 75.
Read more

 

 

  1. Write a function COUNT_DO( ) in C++ to count the presence of a word „do‟ in a text file “MEMO.TXT”.

Example : If the content of the file “MEMO.TXT” is as follows:

I will do it, if you

request me to do it.

It would have been done much earlier.

The function COUNT_DO( ) will display the following message:

Count of -do- in file: 2

Read more

 

Rate Us
error: Content is protected !!