HOME-WORK FOR THE "ONE WEEK HOLIDAY"


NOTE DOWN  the following Key Points in DATA FILE HANDLING :

Read( ) : A function used to read a fixed number of bytes from the  specified file stream object  and puts them in the object  passed as first argument.

General Syntax :   

Straeam_object.read ( (char *) &Oject , sizeof(Object));

Example :
…………………  code………………..

EMPLOYEE emp;  // an object/instance of class created
fstream f;
f.open(“EmpDetails.dat”,ios::in);// an already xisting file containing employs details opened for reading
// if open succeeds  then f contains NON-ZERO VALUE i.e. an address in  main memory allocated for the  //file object….if open fails   f will be zero.

if(!f)  {

    cout<<” file can not be open—OPEN FAILED “;

  exit(1); //send FAILURE=1  MESSAGE TO OPERATING SYATEM AND skip execution of the remaining part //of program.

}

While(!f.eof())

{ Cout<<”\n DETAIL OF EMPLOYEES :  \n”;

 f.read((char*)&emp,sizeof(emp));

// SOURCE  of data :  f   TARGET  : emp object 

//first argument gives address of object where we want to store data after retrieving form file f , second //argument gives the number of UNITS of data to be copied form f to emp.

//(char *) tells that UNIT to be used for counting  is character/byte.  [byte by byte copy operation ]

Emp.display();  //use display() public member func to display  one employee details

}

NOTE :  Similarilly write() also works….. only difference is in  SOURCE and Target of data

f.close();

f.open(“EmpDetails.dat”,ios::out |ios::ate);

int flag=1;

while(flag)

{

     emp.enter();
f.write((char*)&emp,sizeof(emp));  //one object writeen into file object at the end of file

// SOURCE  of data :  emp object     TARGET  : f 
cout<<”\n DO U WANT TO CONTINUE …enter 0 to stop \n”;
cin>>flag;

}   //data written to a file using write() can only be read accurately using read ()


HOME ASSIGNMENT

[PART 1]  DATA FILE HANDLING :

Q1. What are the general steps to be followed while writing a program to handle multiple files in a program?

Q2. Write a prog. To count the number of vowels present in a text file.

Q3. Write a prog. To  calculate average word size of a text file.

Q4.write a prog. To count no. of lines in a text file.

Q5.Write a prog to find out the size of a file in bytes.

Q6.Write a prog to read and write an object using read() and write() using binary file.

                                                                    [PART 2]  BOOLEAN ALGEBRA :

Q7.  Draw a logical circuit diagram for the following Boolean Expression :
X’.(Y’+Z)+Y.Z’+X
Q8. Convert the following Boolean expression into its equivalent Canonical Sum of Product form –SOP:
    (X’+Y+Z’).(X’+Y+Z).(X’+Y’+Z).(X’+Y’+Z’)
Q9. Simplify by using K-MAP :
F(A,B,C,D)=∑(0,1,2,4,5,7,8,9,10,11,14)
Q10. Simplify by using K-MAP :
F(A,B,C,D)= ∏(5,6,7,8,9,12,13,14,15)
Q11. Design NOT, AND ,OR gates using
(a) only NAND gate as basic gate 

(b) using only NOR gate as basic gate
Q12. Verify XY’+X’Y+X’Y’ = (X’+Y’) using (a) Algebraic method (b) Truth Table
Q13.Prove both DeMorgan’s theorems for 4 inputs-   A, B , C  , D  using (a) Algebraic method (b) Truth Table.(we  already know about the 2-input       DeMorgan’s theorems )

              For any queries/doubts feel free to reach me @ Email ID :    HSYADAV.KVS@GMAIL.COM 

********************  THE END **********************

Popular posts from this blog

XII- CS-- SOLVED SQL queries (SQL PRACTICAL ASSIGNMENS)

SQL--HOME ASSIGNMENTS(XII Class)

Python-MySQL Connectivity