NIOS Class 12 Computer Science Chapter 21 Files

NIOS Class 12 Computer Science Chapter 21 Files Solutions English Medium As Per New Syllabus. to each chapter is provided in the list so that you can easily browse throughout different chapters NIOS Class 12 Computer Science Chapter 21 Files Notes and select need one. NIOS Class 12 Computer Science Question Answers Download PDF. NIOS Study Material of Class 12 Computer Science Notes Paper 330.

NIOS Class 12 Computer Science Chapter 21 Files

Also, you can read the NIOS book online in these sections Solutions by Expert Teachers as per National Institute of Open Schooling (NIOS) Book guidelines. These solutions are part of NIOS All Subject Solutions. Here we have given NIOS Class 12 Computer Science Textbook Solutions, NIOS Senior Secondary Course Computer Science Notes for All Chapter, You can practice these here.

Chapter: 21

Module – 3: Programming in C++

INTEXT QUESTIONS 21.1 

1. Fill in the blanks: 

(a) A ______________ is a collection of logically related records. 

Ans: File.

(b) The file opened in ofstream is only available for ______________ .

Ans: Output. 

(c) The file opened in ifstream is only available for ______________ .

Ans: Input. 

(d) We can open the file using _____________ function. 

Ans: Open.

(e) The mode app opens the file for ______________ .

Ans: Output.

(f) The file open in output mode is ______________ by default.

Ans: Truncated.

2. State whether the following statements are true or false: 

(a) A file is a collection of records. 

Ans: True.

(b) The file opened in ofstream is available for writing. 

Ans: True.

(c) The output mode of opening a file deletes the contents, if present in the file. 

Ans: True.

(d) The close ( ) function is used to close a file. 

Ans: True.

(e)  The statement 

      outfile.write ((char*) & obj, sizeof obj); 

      writes only data in obj to outfile. 

Ans: True.

(f) The ios::ate mode allows us to write data at the end of the file only. 

Ans: False.

(g) We can add data to an existing file by opening in append mode. 

Ans: True.

(h) The data written to a file with write ( ) function can be read with the get ( ) function. 

Ans: False.

TERMINAL EXERCISE 

1. What is an input stream? 

Ans: An input stream is a channel through which data flows from an input device or source into a program for processing.It allows the program to receive data from sources like the keyboard, files, or other devices.

2. What is the difference between opening a file with constructor function and opening a file with open () function?

Ans: 

Constructor Functionopen() Function
The file is opened at the time of object creation.The file is opened after creating the object.
Simpler and shorter method.More flexible method.
Example: ifstream fin(“data.txt”);Example: ifstream fin; fin.open(“data.txt”);

3. What is the file access mode? Describe the various file modes. 

Ans: File access modes specify the purpose for which a file is opened.

Various file modes are:

(i) ios::in → Opens file for input (reading).

(ii) ios::out → Opens file for output (writing).

(iii) ios::app → Appends data at the end of file.

(iv) ios::ate → Opens file and moves pointer to end of file.

(v) ios::binary → Opens file in binary mode.

(vi) ios::trunc → Deletes existing contents of file.

(vii) ios::nocreate → Opens existing file only.

(viii) ios::noreplace → Prevents overwriting of existing file.

NEW VIDEO CLASS

Subject Ka Complete Video Solution Dekhein

Step-by-step easy concept explanation aur full questions Answer ke liye watch karein ya app download karein:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top