(Paper) Sample Paper Class - XII Computer Science 2008-6

Disclaimer: This website is NOT associated with CBSE, for official website of CBSE visit - www.cbse.gov.in


File handling ( 6 or 7 marks)

  1. Write a function in C++ to read the content from a text file STORY.TXT, count and display the number of alphabets present in it.




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





  3. Assuming the class EMPLOYEE given below, write functions in C++ to perform the  following:-

(i)                  Write  the objects of  EMPLOYEE  to binary file.

(ii)                 Reads the objects of EMPLOYEE from binary file and display them on screen.

      Class EMPLOYEE

                 {

                  int ENC;

                  char   ENAME[0];

                  PUBLIC:

                      Void GETIT(){ cin>> ENO;gets(ENAME);}

                  Void  SHOWIT() { cout>> ENO<<ENAME;<<endl; }

                   };

 

 

 

 

  1. Assuming the class STOCK, write  functions in C++ to perform following:

(i)                  Write the objects of  STOCK to binary file.

(ii)                Reads the objects of STOCK from binary file and display them on screen.

         Class STOCK

       {

                      int   ITNO;

                      char ITEM[10];

           PUBLIC:

                       Void GETIT() { CIN>> ITNO; gets(ITEM);}

                       Void SHOWIT() { cout<<ITNO<< “     ” <<ITEM<<endl ;}

        };

 

 

 

  1. Consider the class declaration

       Class BUS

        {

                        int  bus_no;

                        char destination[20];

                        float distance;

                    PUBLIC:

                         void read(); // read the data from file

                         void Write(); // read the data from user and store to the file .

                         void show();      // show the data on screen

         };

   Complete  the member functions definitions.

 

 

  1. Consider the following class declaration:

      Class  FLIGHT

        {

                     int flight_no;

                     char  destination[20];

                     float  distance;

           PUBLIC:

                     void  INPUT(); // read from user

                     void  Write_File(); // write the data to file

                     void   OUTPUT(); // read from file & show on screen

         };

      Compute  the member functions definitions.


  1. Write a C++ program, which reads one line at a time form the disk file TEST . TXT ,  and  displays it to  a monitor. Your program has to read all the contents of the file. Assume the length of  the line not to exceed 80 characters. You have to include all the header files if required.





  2. Following is the structure of each record in a data file named “Colony.dat”

struct Colony

{

char colony_code[10];

char colony_name[10];

int no_of_people;

};

 

            Wite a function to update the file with a new value of No_of_people. The value of colony_code and no_of_people are read during the execution of the program.

 

 

  9.  Asuming  a binary  file FUN.DAT   is containing  objects belonging to a class LAUGHTER(  as        defined below). Write a user defined function in C++ to  add more objects belonging  to class       LAUGHTER at the bottom  of it.

                    Class  LAUGHTER

                     {  

                                       int   idno;

                                       char  Type[5];

                                       char Desc[255];

                      PUBLIC:

                         void  Newentry(){    cin>> Idno; gets(Type); gets(Desc);}

                         void Showonscreen()      {  cout<<Idno<<” “<<Type<<endll<<Desc<<endl;}

                    };

 

 

10. Assuming that a text file named TEXT1.TEXT already contains some text written into it, write a       function named vowelwords(), that reads the file TEXT1.TEXT  and creates a new  file named        TEXT2.TEXT,which shall contain only  those words from the file TEXT1.TEXT   which  does not start with an  uppercase vowel(i.e, with ‘A’,’E’,’I’,’O’,’U’). FOR  example, if the file TEXT1.TXT

      contains.

      Carry umbrella and Overcoat when it  Rains

      then the file TEXT2.TXT  shall contain

      Carry when it Rains.

11. Differentiate between read  and get function of istream class.

 

 

12. Write a  C++ program, which initializes a string variable to the content. “ Anil  is a great teacher but       unfortunately it kills all its pupils. Harimohan” and output the srtring one character at a time to the disk file OUT.TXT. You have to include all the header files if required.

 

 

13. A text file named “report.txt” exists on a disk. Write  a program to create its copy named       “Finerep.txt”, which should  be  in   small letters but the first letter of the file and first alphabetic    character following  a full stop should be in uppercase.

 

 

14.. Write  a function in C++ to display the data for for a particular book name from  a binary file “BOOK.DAT”, assuming the binary file is contained the objects of the following class:

 

         class BOOK

         {

                        int Bno; char Title[20];

                        PUBLIC:

                         int Rbno(){return Bno;}

                         void Enter(){cin>>Bno;gets(Title);}

                        void Display(){cout<<Bno<<Title<<endl;}

                        char * retname() { return Title; }

 

         };

 

15 . Write a function in c++ to copy all the lines from file text1.text into text2.txt which is starting from ‘A’ letter. Assuming that each and every line does not exceed from 50 characters.

 

< Pervious

 Next >


  Go To Page :   1,   2,   3,   456   >>