Similar documents
QUESTION BANK SUB: COMPUTER SCIENCE(083)

(1)Given a binary file PHONE.DAT, containing records of the following structure type class Phonlist { char Name[20]; char Address[30]; char


Sample Paper 2013 SUB: COMPUTER SCIENCE GRADE XII TIME: 3 Hrs Marks: 70

Downloaded from

Disadvantages: Not suitable for long distance due to high attenuation. Low bandwidth support. Low Speed

SAMPLE PAPER-2015 Class-XII SUB:-COMPUTER SCIENCE

After going through this lesson, you would be able to: store data in a file. access data record by record from the file. move pointer within the file

Code No. 083 Time allowed: 3 hours Maximum Marks: 70 Instructions: (i) All questions are compulsory. (ii) Programming language: C++

Downloaded from

Computer programs are associated to work with files as it helps in storing data & information permanently. File - itself a bunch of bytes stored on

Downloaded from 1 Mark Questions Programming in C++

CLASS: XII COM.SCIENCE

(a) Differentiate between a call by value and call by reference method.

JB ACADEMY HALF-YEARLY EXAMINATION 2016 CLASS XII COMPUTER SCIENCE. Time: 3:00 Hrs. M.M.: 70

C++ How to Program 14.6

Convenient way to deal large quantities of data. Store data permanently (until file is deleted).

Object Oriented Programming Using C++ UNIT-3 I/O Streams

Chapter-12 DATA FILE HANDLING

Q4. Based on File Handling 6-8 Marks File Pointers tellg() tellp() seekp()seekg() 1-2 Marks Binary File 4 Marks Text file 2 Marks

Please check that this question paper contains 11 printed pages. Please write down the serial number of the question before attempting it.

ios ifstream fstream

Random File Access. 1. Random File Access

Chapter 12: Advanced File Operations

CLASS XII COMPUTER SCIENCE(083) TimeAllowed : 3 HrsMax Marks : 70

Unit-V File operations

This chapter introduces the notion of namespace. We also describe how to manage input and output with C++ commands via the terminal or files.

Advanced File Operations. Review of Files. Declaration Opening Using Closing. CS SJAllan Chapter 12 2

DATA FILE HANDLING FILES. characters (ASCII Code) sequence of bytes, i.e. 0 s & 1 s

C++ Binary File I/O. C++ file input and output are typically achieved by using an object of one of the following classes:

File.seekp(File.tellp( )-sizeof(c)); //Statement 1 //File.seekp(Record*sizeof(C));

Chapte t r r 9

BRAIN INTERNATIONAL SCHOOL. Computer Science Assignment CLASS XII OCTOBER 2018 Chapter-7. Data File Handling in C++ Text Files

JB Academy, Faizabad Half Yearly Examination Subject: Computer Science (083) Class XII

Consider the following example where a base class has been derived by other two classes:

More File IO. CIS 15 : Spring 2007

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat Ch - 7. Data File Handling

Study Material for Class XII. Data File Handling

IS 0020 Program Design and Software Tools

Mock Test Paper-3. Computer Science. Duration : 3hrs Max Marks : 70

(d) Rewrite the following program after removing all the syntax error(s), if any. [2] include <iostream.h> void main ( )

Physical Files and Logical Files. Opening Files. Chap 2. Fundamental File Processing Operations. File Structures. Physical file.

Developed By : Ms. K. M. Sanghavi

Data File Handling FILL IN THE BLANKS EACH QUESTION CARRY 1 MARK

VIDYA BHARATI SCHOOL

Computer Science, Class XII, Chapter No.7 (Data File Handling)

C++ Programming Lecture 10 File Processing

C++ files and streams. Lec 28-31

Input and Output File (Files and Stream )

Files Total: // Files Example 1. #include <iostream> #include <fstream>

SUBMITTED AS A PART OF C.B.S.E. CURRICULUM FOR THE YEAR

KE DRIYA VIDYALAYA SA GATHA,CHE AI REGIO. COMMO PRE-BOARD EXAMI ATIO COMPUTER SCIE CE CLASS- XII Time allowed : 3 hours Maximum Marks : 70

Streams contd. Text: Chapter12, Big C++

Object Oriented Programming In C++

Advanced I/O Concepts

MANAGING FILES OF RECORDS

Lecture 9. Introduction

Fundamental File Processing Operations 2. Fundamental File Processing Operations

Fundamentals of Programming Session 27

BITG 1113: Files and Stream LECTURE 10

void main() { int global=7 ; func( ::global,global) ; cout<<global<<, <<::global<< \n ; func(global,::global) ; cout<<global<<, <<::global<< \n ; }

DAV PUBLIC SCHOOLS, ODISHA, ZONE-II QUESTION BANK CLASS: XII-COMPUTER SCIENCE (083)

CSc Introduc/on to Compu/ng. Lecture 19 Edgardo Molina Fall 2011 City College of New York

CBSE GUESS PAPER. Roll No. Computer Sc. XII(083)/

Input/output. Remember std::ostream? std::istream std::ostream. std::ostream cin std::istream. namespace std { class ostream { /*...

Fall 2017 CISC/CMPE320 9/27/2017

CSC 138 Structured Programming CHAPTER 4: TEXT FILE [PART 1]

DELHI PUBLIC SCHOOL BOKARO STEEL CITY

KENDRIYA VIDYALAYA SANGATHAN, COMPUTER SCIENCE (THEORY) I PRE-BOARD TIME 3 HRS CLASS XII M. Marks 70

Chapter 14 Sequential Access Files

VuZs Team's Work. CS201 Spring Solved by vuzs Team with Reference Written by Administrator Wednesday, 19 May :52

Introduction to Computer and Program Design. Lesson 6. File I/O. James C.C. Cheng Department of Computer Science National Chiao Tung University

by Pearson Education, Inc. All Rights Reserved. 2

Streams in C++ Stream concept. Reference information. Stream type declarations

DISK FILE PROGRAM. ios. ofstream

Model Sample Paper 2015

BHARATIYA VIDYA BHAVAN S V.M.PUBLIC SCHOOL, VADODARA. Class : XII SAMPLE PAPER Max Marks : 70

COMP322 - Introduction to C++

Chapter 8 File Processing

SAMPLE PAPER-2015 CLASS-XII COMPUTER SCIENCE. Sample paper-i. Time allowed: 3 hours Maximum Marks: 70 Name : Roll No.:

CBSE 12th Computer Science Question Papers

Programming II with C++ (CSNB244) Lab 10. Topics: Files and Stream

UNIT V FILE HANDLING

KENDRIYA VIDYALAYA SANGATHAN TINSUKIA REGION PRE BOARD EXAMINATION SUBJECT COMPUTER SCIENCE

KENDRIYA VIDYALAYA SANGATHAN (CHANDIGARH REGION) MARKING SCHEME (Ist Pre Board )

Sample Paper, 2015 Subject: Computer Science Class 12 th

Downloaded from

Quiz 3 CSCI 333 Fall December, 2001

SHORT REVIEW OF CS TOPICS RANDOM NUMBERS (2 MARKS) which generates a random number in the range of 0 to n-1. For example;

COMPUTER SCIENCE

KendriyaVidyalayaSangathan Kolkata Region

System Design and Programming II

Item 1: Switching Streams

Managing Files of Records

UEE1303(1070) S 12 Object-Oriented Programming in C++

DATA FILE HANDLING. The function should create another file OUT.TXT with the text

KENDRIYA VIDYALAYA SANGATHAN

10/23/02 21:20:33 IO_Examples

KENDRIYA VIDYALAYA SANGATHAN ERNAKULAM REGION FIRST COMMON PRE BOARD EXAMINATION

A stream is infinite. File access methods. File I/O in C++ 4. File input/output David Keil CS II 2/03. The extractor and inserter form expressions

Transcription:

High Order Thinking Skill Questions Subject : Computer Science Class: XII 1 Mark Questions Programming in C++ 1. Observe the program segment carefully and answer the question that follows: int getitem_no( ) return item_no; ; void modify(item x, int y ) File.open( item.dat, ios::binary ios::in ios::out) ; int recordsread = 0, found = 0; while(!found && File.read((char*) &i, sizeof (i))) recordsread++; if(i. getitem_no( ) = = y ) //Missing statement found = 1; if(! found) cout<< Record for modification does not exist ; If the function modify( ) is supposed to modify a record in the file item.dat, which item_no is y, with the values of item x passed as argument, write the appropriate statement for the missing statement using seekp( ) or seekg( ), whichever is needed, in the above code that would write the modified record at its proper place. 2. Observe the program segment carefully and answer the question that follows: class member Page 4

int member_no; char member_name[20]; int getmember_no( ) return member_no; ; void update(member NEW ) File.open( member.dat, ios::binary ios::in ios::out) ; member i; if(new. getmember_no( ) = = i. getmember_no( )) //Missing statement File.write((char*) &NEW, sizeof (NEW)); If the function update( ) is supposed to modify the member_name field of a record in the file member.dat with the values of member NEW passed as argument, write the appropriate statement for the missing statement using seekp( ) or seekg( ), whichever is needed, in the above code that would write the modified record at its proper place. 3. Observe the program segment carefully and answer the question that follows: void enterdetails( ); int getitem_no( ) return item_no; ; void modify(item x ) File.open( item.dat, ) ; //parameter missing if(x. getitem_no( ) = = i. getitem_no( )) Page 5

else File.seekp(File.tellg( ) sizeof(i)); File.write((char*) &i, sizeof (i)); 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. 4. Observe the program segment carefully and answer the question that follows: class member int member_no; char member_name[20]; void enterdetails( ); int getmember_no( ) return member_no; ; void update(member NEW ) File.open( member.dat, ios::binary ios::in ios::out) ; member i; if(new. getmember_no( ) = = i. getmember_no( )) File.seekp(, ios::cur ) //Paremeter Missing File.write((char*) &NEW, sizeof (NEW)); If the function update( ) is supposed to modify a record in the file member.dat with the values of member NEW passed as argument, write the appropriate parameter for the missing parameter in the above code, so as to modify record at its proper place. 5. A file named as STUDENT.DAT contains the student records, i.e. objects of class student. Write the command to open the file to update a student record. (Use suitable stream class and file mode(s). Page 6

6. A file named as STUDENT.DAT contains the student records, i.e. objects of class student. Assuming that the file is just opened through the object FILE of fstream class, in the required file mode, write the command to position the put pointer to point to second record from the last record. 7. A file named as STUDENT.DAT contains the student records, i.e. objects of class student. Assuming that the file is just opened through the object FILE of fstream class, in the required file mode, write the command to position the get pointer to point to fifth record from the beginning. 8. Read the code given below and answer the question: void main( ) char ch = A ; fstream outfile ( data.dat, ios::out); outfile<<ch<<ch; If the file contains GOOD before execution, what will be the contents of the file after execution of this code? 9. Observe the program segment carefully and answer the question that follows: class student int student_no; char student_name[20]; int mark; void change_mark( ); //Function to change the mark int getstudent_no( ) return student_no; ; void modify( int y ) File.open( student.dat, ios::binary ios::in ios::out) ; student i; int recordsread = 0, found = 0; while(!found && File.read((char*) & i, sizeof (i))) recordsread++; if(i. getstudent_no( ) = = y ) i. change_mark( ); //Missing statement 1 //Missing statement 2 found = 1; if( found = = 1) cout<< Record modified ; Page 7

If the function modify( ) is supposed to change the mark of a student having student_no y in the file student.dat, write the missing statements to modify the student record. 10. Observe the program segment carefully and answer the question that follows: int getitem_no( ) return item_no; ; void modify(item x ) File.open( item.dat, ios::binary ios::in ios::out ) ; //Statement 1 if(x. getitem_no( ) = = i. getitem_no( )) File.seekp(File.tellg( ) sizeof(i)); If the function modify( ) modifies a record in the file item.dat with the values of item x passed as argument, rewrite statement 1 in the above code using ios::eof( ), so as to modify record at its proper place. 2 Marks Questions Programming in C++ 1. What is wrong with the following while loop: a. int counter = 1; b. int counter = 1; while ( counter < 100) while ( counter < 100) cout << counter << \n; cout << counter << \n; counter + +; counter - -; 2. What will be the output of following: void main ( ) int val = 10; cout << val ++ << val << ++ val; Page 8