Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
98 views
Computer Science Passing Package
Cs
Uploaded by
nikithdr028
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Computer_Science_Passing_Package For Later
Download
Save
Save Computer_Science_Passing_Package For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
98 views
Computer Science Passing Package
Cs
Uploaded by
nikithdr028
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Computer_Science_Passing_Package For Later
Carousel Previous
Carousel Next
Save
Save Computer_Science_Passing_Package For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 69
Search
Fullscreen
iekstJ a6} my se & TpuCc Computer Science11 PUC COMPUTER SCIENCE(41) PASSING PACKAGECHAPTER 1: TYPICAL CONFIGURATION OF COMPUTER SYSTEM 1 ONE MARK QUESTIONS: 1, Expand UPS. Ans. Uninterruptible Power Supply 2. Expand SIMM. ‘Ans, Single In-line Memory Module 3. Expand DIMM. cy Se alan Mcmmy Module NO 4. Expand SMPS. Ss ‘Ans, Switched Mode Power Supply «wo \ 5. Expand USB. ao oo 6. Expand DDRAM. ‘Ans. Double Data Rate Random Access Memory wy “ 7. Expand PCI. Ans, Peripheral Component Interconnect B.Expand IA. ox ‘Ans. Industry Standard Architecture \\ 9. Expand SDRAM. Q) ‘Ans. Synchronous Dynami cra AS Memory 10, What is motherboard Ans. It is a hub which is used to connect all the necessary components of the computer. OR The motherboard is a large printed circuit board which contains all major parts. Itis the main circuit board of computer system 11, What is Microprocessor? ‘Ans. Microprocessor or CPU is a complete computation engine that is fabricated on a single chip, 12, What is a port? Ans. Ibis the socket on the back of the computer which is used to connect external devices to the motherboard. (OR 1A place to connect the input/output and peripheral devices to computer system 13, What is a bus? ‘Ans. Bus is a set of electrical conducting lines through which binary information is transferred. (CR) A Bus is a communication system that transfers data between components inside a computer 14, What is Cache Memory’ Ans. Its a small, very fast memory that exists between the RAM and the CPU. 15, Where is L1 and L2 located? ‘Ans. LI resides with in CPU (it is also called On-Chip cache) L2 resides on Motherboard (it is also called Off-Chip cache) 16. What is SMPS? Ans. SMPS is a voltage re; components. 17. What is meant by Plug and play Device? Ans. Plug-Play device means devices can be inserted or removed into/from the computer system without turning the computer OFF or without adding an adapter car. 18. What is Register? ‘Ans. Registers are high speed storage units within the CPU, but have least storage capacity. 19. Expand BIOS. Any: Basic Input Output System IL. TWO MARKS QUESTIONS 1. Explain any 2 characteristics of motherboard. > Form Factor: It includes motherboard’ electrical requirement, geometry, dimension and arrangement, > Chipset : It is a collection of microchips (such as CPU,BIOS, memory, mass storage, interfaces, controllers and VO devices)designed with built-in circuits on motherboard to work together to perform funeti TER SCIENCE (41) Page | ator which converts AC Power to DC Power and supplies power needed by system 1 PUC COMPU (O scanned wih nen Scanner,eee > Processor Socket Judes the type of CPU socket used to insert the CPU. It is designed as per the compatibility of the CPU on the motherboard. Example: PGA socket, LGA socket. 2, Explain any 2 types of motherboard. > XT Motherboard: XT stand for eXtend Technology. These are old model motherboard. In this motherboard, we find old model processor socket LIF(Low Insertion Force) sockets, DIMM ram slots and ISA slots, [2pin power connector and no ports. AT Motherboard: AT Stand for Advanced Technology Motherboards. They have PGA(Pin Grid Array) Socket, SDRAM slots, 20 pin power connector, PCI slots and ISA slots. Example: Pentium III Processors > Baby AT Motherboard: Baby AT Motherboards have the combination of XT and AT. They have slot type processor sockets and PGA processor sockets, SDRAM slots and DDRRAM slots, PCI slots and ISA slots, 12 pin power connector and 20 pin power connector and ports. Example: Pentium-IIl and Pentium- v > ATX Motherboard: ATX stand for Advanced Technology eXtended. Latest motherboard is called as ATX motherboard. In this motherboard, we find MPGA processor sockets, DDRRAM slots, PCI slots, AGP slots, SATA connectors, 20 pin and 24 pin ATX POWER CONNECTOR AND PORTS. Example: Pentium-IV, Dual Core, Core 2 Duo, Quad Core.i3,i5, and i7 processors 3. Explain any 2 different types of buses. } Address Bus — It carries address of the data in the memory which is to be read from/write into, Width of the address bus determines the number of memory locations the computer can address.Example:36-bit address bus can address 236=64GB of memory location Data Bus - Provides a path to transfer data and instruction between CPU and memogy¢Width of data bus is ¥ ¥ ‘¢ 32-bit, 64-bit ete, a Control Bus-It carries control signals sent from CPU to different parts, y mputer. It also used to direct and monitor the actions of the other functional parts ofthe cofypuiyrapstem. 4. Explain the different types of UO ports (Any 2). \) > These ports are also called as communication ports. % The /O ports connects the external devices to the apn > Serial Port: Serial Port is also known as epmmulicaKion (COM) ports or RS232¢ ports. They are used for connecting communication devices Ii Jn mv, This pom transfers data sraly one bit at > Parallel port: Parallel por 10 connect external /O devices like printers or scanners. This port facilitates the parallel Poss OF data, usually one byte(8-bits) at a time. > USB —port: It is, VO port. Gives a single, standardized, easy-to-use way to connect a variety of newer per computer IDE “ings tal Electronics) port: IDE devices like CD-ROM drives or hard disk drives are connected the motherboard through the IDE port. AGP (Accelerates Graphies Port) port: The AGP port is used to connect graphic card that provides high-speed video performance. typically required in games and others multimedia applications. 5, Explain the function of UPS and its types. > An UPS is a power supply device that includes a battery to maintain power in the event of a power failure, > Typically, an UPS keeps a computer running for several minutes to few hours after a power failure > Types of UPS 1. Online UPS: An online UPS avoids those momentary power lapses by continuously providing power from its own inverter, even when the power line is functioning properly. Online UPS is more costly than Standby UPS. ndby UPS: A Standby UPS (or OFF-LINEUPS) Monitors the power line and switches to tery power as soon as it detects a problem. The switch over to battery, however, can require several milliseconds, during this time the computer is not receiving any power. 6. Explain Cache memory > The cache memory is a high speed memory available inside CPU to speed up access of data and instructions stored in RAM memory. > Cache memory temporarily stores data that is used more often and makes it available to CPU at a fast rate > Hence itis used to increase the speed of processing, 7. Explain any 2 components of the Motherboard. ¥ ¥ I PUC COMPUTER SCIENCE (41) Page 2 (O scanned wih nen Scanner,eee 1. Processor (CPU): The processor or CPU is the main component on the motherboard and is called as the brain of the computer. It consists of ALU, CU registers 2. BIOS Chip (Basic Input Output system): BIOS is a small chip on the motherboard that holds a set of instructions to load the hardware settings required to active various devices like keyboards, monitors or disk drives. The BIOS runs when the computer is switched ON. It performs a Power On Self-Test (POST), that checks the presence of hardware devices and are functioning properly 8, What is expansion slot? Mention any TWO types. > Ibis an opening on the motherboard into which expansion boards (peripheral cards) are inserted to improve the functionality or capability of the computer. Example: After installing a sound card on the expansion slot, sound capability of the computer can be improved or added. TYPES: ISA, PCI, AGP slot ISA (Industry Standard Architecture) Slot- ISA slot is used to connect modem and input devices. PCI (Peripheral Component Inter Connect) Slot- PCI slot is used to connect graphics accelerator cards, sound cards, internal modem or SCSI cards, they are mush faster than ISA cards. AGP (Advanced Graphic Port) Slot- It is used to connect graphies accelerator cards and 3D accelerator cards, It enhances the visual experience for the user in multimedia applications and games. IIL FIVE MARKS QUESTIONS 1, What is port? Explain any four types of port. Port is a connector or place used to connect input / output or peripheral devices to computer system ‘Types of port vy ¥ > Serial port-- It transmits 1 bit at a time, It needs single communicating wire to interface with the computer > Parallel port tt transmits 8 bit at a time, It needs 8 mee Interface with the computer > USB -PORT-Universal serial bus port, ANS > AGP Port Accelerated graphics port -Used to connect ni cad that provides high speed video performance specially required in games and ot em plication > VGA PORT. Visual graphics adaptor BCederct ‘monitor to computer's video card. 2.What is bus? Explain eilferent types of oak components inside a computer. ‘Types based on location of path that uansfers data and instructions between the =¥ a on motherboatd ike proceso, RAM et. Its socalled system Internal: It connect bs XS Extemal: It an interface for peripheral devices like HDD, CD-ROM ete, to connect with processor falled as expansion bus. ‘Types based on 1 fanctionalits Control BUS: It is used by the processor to send control signals to different components and to maintain co-ordination with TCU. Data BUS: It provides the path to transfer data and instructions between CPU and memor ‘Address BUS: It provides the transfer of physical address of the data and instructions in the main memory. Define a)Bus b)Port c)Microprocessor d)Cache memory e)Disk controller ‘A Bus is a collection of wires that carries electrical signals from one component to another Portis a socket used to connect external devices to the computer Microprocessor is single integrated circuit chip that function as computer CPU Cache memory is a small, fast intermediate memory present in between CPU and RAM Disk controller-is a circuit that enables the CPU to communicate with hard disk/floppy disk drives 4.Explain the types of power supply. There are two types of power supply connected to a computer system . They are : 1. SMPS [ Switch Mode Power Supply | S [ Uninterruptable Power Supply } -¥ wevvgew I PUC COMPUTER SCIENCE (41) Page 3 (O scanned wih nen Scanner,Nene > SMPS converts AC power from an electrical outlet to the DC power needed by system components. SMPS is a metal box in the rear of the system that is attached to the computer chasis and to the system board > Ina PC the SMPS converts 230 volts of AC to 5 to 12 volts of DC and the wattage is around 180 to 300 watts, 450 watts and 500 watts. 2. UPS: > An UPS is a power supply that includes a battery to maintain power in the event of a power failure or any electrical problems like power line problems, power outages, under voltage or lightening. > UPS keeps a computer running for several minutes to few hours after a power failure, enabling us to save data that is in RAM and then shut down the computer properly. ‘There are two types of UPS 1, Offline UPS or Standby UPS: In offline UPS the input current is directly connected to the device. The UPS circuit always monitors the voltage level in the mains, and if there is a voltage drop or mains failure, it switches on the inverter to give AC power to the device from the inverter until the mains supply returns to normal. 2. Online UPS : In online UPS the inverter is directly connected to the device and it is always on to give the required current to the device. Online UPS avoids momentary power lapses by continuously providing power from its own inverter , even when the power ¥ 5. With a neat block diagram of a computer explain the basic units of computer. islam 1. Input Unit 2. Central Processing Unit(CPU) * Control Unit oe ihe meeeeeeith noorul Computers need to receive data and instructions in order to solve @ problem, The Input unit performs this operation. > The Input Unit basically links the extemal world or environment to the computer system. > The input unit may consist of one or more input devices. Central Processing Unit (CPU): > The function of the CPU is to interpret the instructions in the program and execute them one by one. It consists of two major units, 1. Control Unit: It controls and directs the transfer of program instructions and data between various units. 2. Arithmetic and Logie Unit (ALU): Arithmetic and Logic Unit performs arithmetic and logical operations and controls the speed of these operations Memory Unit: > The results generated from processing have to be preserved before itis displayed. > The memory units thus provide space to store input data, intermediate results and the final output generated. > Note: The input unit, an output unit, and secondary storage devices are together known as Peripheral Devices. Output Unit: > It is used to print or display the results, which are stored in the memory unit. The actual function of the output unit is just the reverse of the input unit > Thus, the output unit links the computer to the outside world, I PUC COMPUTER SCIENCE (41) Page 4 (O scanned wih nen Scanner,mn CHAPTER-2 BOOLEAN ALGEBRA 1. TWO MARKS QUESTIONS: 1, Prove that (X+¥)(X+Z) = X+YZ using algebraic method.Proof:LHS = (X+¥)(X+Z) X +XZ+XY + YZ = X+XZ+XY+YZ (X.X=X) X 4XY+YZ (XX, +YZ (oX+#XY=X) HS 2. Prove that (X + ¥)(X + Y) = X using algebraic meth- od. Proof: LHS=(X + ¥)(X +¥) =XX + YX + XW YY =X+XY¥+XH0 =X+ XY =X =RHS 3. Prove that X+XY=X+Y using algebraic method. . mn “angina witht TOOrUl isla (RX) EX+¥ (1) =X+Y =RHS 4, Prove that X+XY=X using algebraic method Proof: LHS = X+XY =X(+Y)=X.1 (el =X OX =RHS 5. Prove that X(X+Y)=X using algebraic method. Proof: LHS =X(X+Y) X+ XY XY (XXEI) 1 (¥Y=1) (2X IEX) =RHS 6, Define min term and max term. Ans: Minterm is a product of all the literals (with or without bar) within the logic system. Maxterm is sum of all the literals (with or without bar) within the logic system. (O scanned wih nen Scanner,7.What is meant by tautology and fallacy’? ‘Ans: If result of any logical expression is always TRUE or | , then it is called ‘Tautology. If result of any logical expression is always FALSE or O.then it is called Fallacy. 8. What is principle of duality? Give an example. ‘Ans: This theorem states that, starting with a Boolean relation another Boolean relation cabe derived by i, Changing each OR sign (+) to an AND sign (.) and by Changi sign (.) toan OR sign(+) ii, Changing each 0 by | and each 1 by 0. Example: Dual of 1+0=1 is 0.1=0 9. State and prove idempotence Law. Ans: This law states that each AND a) X+X=X b) X.X=X X [X [ex X [x [Xx o jo jo o jo [o rit yi tt 10, State and prove Involution law, = Ans: This law states that X=X . ae islam english witha por 11, State and prove Complementary Law. Ans: This law states that a)X +X = b) xX [xX] xX+x x [x [xx o fi tt of fo 1 fo [t T To 10 12. State and prove commutative law using truth table X. ¥ xX [y¥ [xy YX 0 0 oO 0 0 0 0 1 i XGY Y=X 0 oO 1 i 1 1 1 i II PUC COMPUTER SCIENCE (41) Page 6 © scanned wth OREN Scanner13.Prove that XY+XY =X Algebraic method=XY+XY X(YFY ) (by complementari 1 (property of X. Or Truth table x [y_[¥ [xy [x¥_[xvaxy 0 fo fifo fo To ofa fo fo fo To a 1 rife ft fo SY+XZ+XY 14,Find the complement of the expression Y+XZ+XY_ AWiXEXY) (X+Z).R+¥) 1S.State De Morgan's theorems oorul islam ‘Ans: It states that . h n >arglish. Wit ‘The invefeel bubhoftwd vatidbles is equal to the product of their individual abl inverted vai ‘The inverted product of two variables is equal to the sum of their individual invertedvariables. ani implify the Boolean function (W, X,Y, Z) = (0, 4, 8, 9, 10, 14, 12, 13, 15) using K-map Ans, ‘Thus, the combined reduced sop expression is, Z + WX+ WZ I PUC COMPUTER SCIENCE (41) Page 7 © scanned wth OREN Scanner2. Using k-map, simplify the following exp in 4 variables (4, B,C,D) = mi + mz + ms + ms + mo + Mu + Maz + Maz ato fy Pind wn 4 aa (10 : 7 d +. Combined reduced sop expression is F = CD + BC + ABD + ABCD” 3. Reduce (4, B,C, D) = (1, 5,9, 10, 11, 12, 13, 14) using in K-Map. O10) ON cD IN _ LO 100) a Th (01) aa 1 was} G » 1 110} 4a 1 1 1 5 \ ootul islam s ert ishanith a ABC + ABD + ACD 4. Reduce F (A, B,C, D)= ¥ (0, 4, 6, 7,8, 12, 14, 15) using Karnaugh map. :- Reduced sop expression is +BC 5. Simplify the following Boolean expression using K-Map F (A, B, C, D) =¥ (0, 2, 5, 7, 8 10, 13,15) Combined reduced sop expression is = BD + BD I PUC COMPUTER SCIENCE (41) age 8 © scanned wth OREN Scanner7. Simplify the following Boolean expression using K-Map F (A, B,C, D) =¥ (0, 2,4, 5.6, 7, 8, 10,12,13,14,15) o ow wo an mt 1 r 1 wot 1 1 1 +- Combined reduced sop expression is =D + BD 8, Simplify the following Boolean expression using K-Map F (A, B, C, D) =¥ (1, 2, 3, 5,7, 8,9, 11,13, 15) english with noorul islam + Combined reduced sop expression D+ ABC-+ABC I PUC COMPUTER SCIENCE (41) age 9 © scanned wth OREN ScannerCHAPTER 3: LOGIC GATES 1. ONE MARKS QUESTION! 1, Write the Logic symbols and Truth Tables for AND,OR,NOT, NAND ,NOR and XOR gates, Ans: Digital Logic Gate Symbols Sax sxsunot Roxane Taare Tams sn -- a loo oe XOR A@Bilsit ¢ 2. What is universal gate. . is; Universal g: Is a gi isi /hich all the basic gates can be desigijed. Hiaeanaba malities oe ATT SLAIM Dee Witt nO eng! vesos [A] 21 : HE 4. What is logic gate? ‘Ans: A Gate isa simply an electronic citeuit which operates on one or more input signals and always produces an output signal. 5.Mention the different universal gates, ‘Ans: NAND gate and NOR 6. NOT gate is also called as ‘Ans: Not gate is also called as Inverter I PUC COMPUTER SCIENCE (41) ize 10 OF scanned wth OnENScnnervy ¥ I. FIVE MARKS QUESTION: 1 Realize NOT,AND and OR gate using NAND Gate NOT GATE: OR GATE: 2.Realize NOT,AND and OR gate using NOR Gate Be > 3. Explain NAND and NOR gate with Logie symbol and Truth Table. NAND gate has two or more input signal but only one output signal ‘The NAND gate is a complemented of AND gate. ‘The output of NAND gate will be 0 only when all inputs are 1 and output will be 0 if any input represents a O. NAND is short form of NOT-AND. ° 1 ° 1 I PUC COMPUTER SCIENCE (41) Page I) © scanned wth OREN Scanner» NOR gate has two or more input signal but only one output signal. > The NOR gate is a complemented of OR gate. > The output of NOR gate will be 1 only when all inputs are 0 and output will be 0 if any input repre- sents al > NOR is short form of NOT-OR Ips 4.Explain XOR and XNOR gates with Logic symbol and Truth Table. > Anexclusive-OR has two or more input signal but only one output signal. > Exclusive-OR gate is different form of OR gate > Exclusive-OR gate produces output | for only when the input combinations are different. > The output is 0 if the input combinations are same, lam igh. with noorul is engli venee [TELE XNOR gate ‘The XNOR gate is complement of XOR gate. > The output of XNOR is | only when the logic values of both X and Y is same i.e. either both are equal to 1 or both are 0. > Its output is 0 when its inputs are different. > In Boolean algebra, © sign stands for XNOR operation. Thus A XNOR B can be > written as A OB ) >“ B B) =(A.B+ AB) I PUC COMPUTER SCIENCE (41) Page 12 © scanned wth OREN ScannerCHAPTER 4 DATA STRUCTURES I. ONE MARK QUESTIONS: 1, What is Data structure? Data Structure is the way of collecting and organizing the data in such a way that we can perform operation on these data in an effective way. 2. What are primitive data structures? Data structures that are directly operated upon the machine-level instructions are known as pr structures. 3. Give any two examples for primitive data structures. The integers, float, character data, pointers are primitive data structures. 4, What are non-primitive data structures? The Data structures that are derived from the primitive data structures are called Non-primitive data struc- ture. 5. Mention any two examples for non- primitive data structures? Array, stack, queues, linked list, tee and graph are non- primitive data structures 6. What are lists? Lists are linear collection of data items. 7. What is meant by linear data structures? \ \ is\ aly \ Linear Data structures are kind of data strugture that thE ROSFU 8. What are non-linear a s ree |, wither A Non-Linear Data stot ch data item is connected to several other data items. 9, Define an array. ‘An array is an ordered collection of elements of same data type that share common name 10. Differentiate between one-dimensional and two-dimensional array. In one-dimensional array we use only one subscript to identify an element where as in two dimensional ar- rays we use two subscripts, 11. What do you mean by traversal operation? The processing of accessing each element exactly once to perform some operation is called traversing 12. Define searching. ‘The process of finding the location of a data element in the given collection of data elements is called as searching 13. Mention the types of searching in the array. Linear Search and Binary Search. 14. Define sorting. The process of arrangement of data elements in ascending or descending order 15. What is a stack? A stack is an ordered collection of items in which an element may be inserted or deleted only at same end. 16. Name the data structure which is called LIFO. ALLIFO (Last In First Out) data structure is also called as stack 17. What is LIFO list? A stack data structure which follows LIFO (Last In First Out) li 18. What are the operations that can be performed on stacks’ Stack( ), push(item), pop( ), peek( ), isEmpty( ), size( ) are the operations of stack. 19. Define the term PUSH and POP operation in stack. > The process of adding one element or item to the stack is represented by an operation called as the PUSH operation. > The process of deleting one element or item from the stack is represented by an operation called as the POP operation. SO I PUC COMPUTER SCIENCE (41) Page 13 ve data alled sorting. principle. © scanned wth omen scamer20. Mention any one application of stacks. > Ibis used to reverse a word. > “Undo” mechanism in text editor » Polish Notation 21. What is a queue? A queue is an ordered collection of items where an item is inserted at one end called the existing item is removed at the other end, called the “front 22. What is the other name of queue? Other name of queue is FIFO. 23. What is FIFO list? In a FIFO list, the first element added to the list will be the first one to be removed. 24. Mention the different types of queues. Different types of queues are Linear queue, Circular queue, Double ended queue, Priority queue 25, What are the operations that can be performed on queue? Queue( ), enqueue(item), dequeue( ), isEmpty ). size( ). 26. What is a linked list? A linked list is a linear collection of data elements called nodes. 27. Which data structure creates relationship between data elements thro) tne | al Y \ Linked List creates relationship between, o elementshifough tO Oo 28. What is binary tree? A binary tree is an 0 Se GwS adh, 1, WAL itt can have maximum of two child nodes connected toi 29, What do you mean by depth of a tree? ‘The height or depth of a tree is defined to be the maximum number of nod 30. How do you find the degree of tree? ‘The degree of tree is the maximum degree of nodes in the tree. The degree of node is the maximum number of children that can exist for a node, in-a branch of tree, I. THREE MARK QUESTIONS: 1. Explain memory representation of two-dimensional array. Let A be a two-dimensional array having M rows and N columns. The array elements will be represented in the memory by a block of M*N sequential memory locations. The array elements may be stored in the memory in any one of the following methods: 1) Row- major representation: In this representation, the first-row elements of the array occupy the first set of memory locations, second row elements occupy the next set of memory locations. To find the memory address of an element in the Ith row and Jthcolumn of the matrix of order M*N is LOC(AII|[J}) = Base(A) + WCN * 1 +3) Where Base(A) is address of first element and W is word size in byte 2) Column-major representation: In this representation, the first- column elements of the array occupy the first set of memory locations, second column elements occupy the next set of memory locations. To find the memory address of an element in the i row and Jthcolumn of the matrix of order M*N is LOCCAIII[J}) = Base(A) + WOM * J +1) Where Base(A) is address of first element and W is word size in bytes, 2. Write an algorithm for traversing the array. (ep 1: For T= LB to UB Do Step 2: Apply PROCESS to A(t} [End of for loop] Step 3: Exit I PUC COMPUTER SCIENCE (41) Page 14 © scanned wth OREN Scannerlention the dif RRR 3. Mention the different types of queue. ‘The different types of queue are: > Simple queue (Linear queue) > Double Ended Queue (DEQUEUE) > Circular queue > Priority queue 4. Different operations on stack Different operations on stack are: > push(item) : Adds a new item to the top of the stack and increases the size of the stack by one (top =top +1) pop(): Removes the top item from the stack and decreases the size of the stack by one ( top = top ~ I ) peek() : Returns the top item from the stack but does not remove it. isempty() : Test whether the stack is empty. size() ; Returns the number of items present in the stack. overflow() :Tests whether the stack is Full underflow () ‘Tests whether the stack is empty. stack() : Ceates a new stack that is empty. vyvvvvy Different operations on queue ferent operations on queue are: 1. queue() : Creates a new queue that is empty. 2. enqueueCitem) : Adds a new item to the rear of the queue and increases the size of the queue by one 3. (rear =rear + 1). 4 5 Di dequeue() : Removes the front item from the queue( front = front + 1 ) isempty() :Tests to see whether the queue is empty. 6. size() :Returns the number of items present in the queue. 6, Write an algorithm for inserting an element into the array. 7stam Step 1 for T=N-1 downto P aaa . th noorul Get english With M Siep3:N=Nel Step 4: Exit ‘7.Write an algorithm for deleting an element from the array. ‘Step 1 Kem= AIP] Step 2: for 1 =P downto N-2 AI] = Alls] [End of for loop] Step 3:N=N-1 Step 4: Exit 8. Mention different types of linked list. ‘The different type of linked lists are: 1. Singly linked list 2. Doubly linked list 3. Circular linked list Five-mark questions I PUC COMPUTER SCIENCE (41) © scanned wth omen scamerWhile(LOW <= HIGH) MID = (LOW + HIGH)/2 U (ELE = A[MID) then LOC = MID Goto Step 1 Step 8: Iifele
= 0) ‘Step 12: Print ele Found in Location LOC Step 13: else ‘Step 14: Print ele not Found [End if] Step 15: Exit MID + 1 10. Write an algorithm for insertion sorting. ‘Step 1: For t= 110 N-T Step 2:J=1 ‘Step 3: while(J>= 1) Step 4: if (AUJ] < AU-1) then Sep: ABT al) lish with noor ul islam ‘Step 6: AU] tui “eng Step 8:3 =1 {End of while loop] [End of for loop] 11. Write an algorithm for Push ‘Step I: [Check for Overflow] WTOP =N-1 Then Print "Stack is full or overflow” Exit [end if] ‘Step 2: TOP = TOP + 1 ‘Step 3: STACK [TOP] = ITEM Step 4: Return 12. Write an algorithm for pop. Step 1: [Check for Undertow] 1TOP =-1 Then Print “Stack is empty or Underflow Exit (End 1 Step 2: ITEM = STACK [TOP] Step 3: TOP = TOP -1 Step 4: return (TEM) OO I PUC COMPUTER SCIENCE (41) © scanned wth omen scamer13. Write an algorithm for Enqueue( Insertion in a queue). ‘Step I: [eheek Tor overflow] IWREAR = N- I then Print “Queve is full or overflow Exit {End if) REAR = REAR + | {End it Step 3: Q(REAR] = ITEM Step 4: Return 14, Write an algorithm for Dequeue(Deletion in a queue). ‘Step I: [check for Underflow] MWERONT =- | then Print “Queue is empty o underflow” Exit (End it) tep 2: ITEM = Q|FRONT} ij m =" english with noorul isla REAR Else FRONT = FRONT $1 End if] Step 4: Return (ITEM) 15. Mention the applications of stack. 1. Polish notation 2. Recursion 3. Evaluation of Postfix Expression 4. Checking for balanced brackets or parentheses matchis 5. Reversing a string 16. Mention the applications of queue. ‘Simulation Various features of operating system. . Multi-programming platform systems. Different type of scheduling algorithm. Round robin technique or algorithm. ILL FIVE MARK QUESTIONS: 1.What is non-primitive data structure? Explain the different operations performed on non-primitive data structure. Non Primitive data structur > The Data structures that are derived from the primitive data structures are called Non-primitive data structure. > They stress on formation of groups of homogeneous and heterogeneous data elements. These data structures are used to store group of values, > _Bg-arrays, lists and files, Operations of non-primitive data structure- I PUC COMPUTER SCIENCE (41) Page 17 © scanned wth OREN Scanner1. Traversal: It is the process of visiting each element in the data structure exactly at once to perform certain operation it Insertion: It is the process of adding a new element to the structure. Deletion: It is the process of removing on item from the structure Searching: It is the process of finding the location of a data item in the given collection of data items is called as searching. Sorting: It is the process of arranging the data items in particular order. 6. Merging: Its the process of combining the data items of two structures to form a single structure. 2. Write an algorithm for insertion sort. Algorithm: Let A be an array with N unsorted elements. The following algorithm sons the elements inorder. Step I: for I=L 10 N-1 top 2 Je While G>=!) MAU] < AU-t) Temp=A[3} AU]= AU-1) AU-1] = temp Mend 1 While end Forend Step 3: Exit 3.What do you mean by deletion? Write an algorithm for deleting an element from an array. STEP TELE = MIPT STEP 2: FOR T= PTO N-I STEP 3: M(t] = Mit+1] [END OF STEP 3 FOR LOOP] STEP 4:} 1 {END IF] 4.Write an algorithm to perform the Binary search operation. -TLOC=1 Step 2 whe Mime . oO iteLE= ais) . ah no en sh wl cos AL\GII ‘if(ELE
=) PRINT “L0G te PRINT Seach susie ‘Write an algorin to Taser an eet atthe begining of he Tnked TS cps Biep2 an mde ‘Step3: INFO[I rul islam Step 4: LINKIP} IL PUC COMPUTER SCIENCE (41) rage 18 © scanned wth omen scamerel 6.Write an algorithm to insert an element ‘Step I: I REAR = N-I Then PRINT “Overflow” Exit Siep 2: If FRONT = NULL Then to a queue. REAR = REAR + | ‘Step 3: QUEUE[REAR] = ITEM Step 4: Return ‘7.What is Primitive data structure? Explain different operations on Primitive data structures. ‘The data structures which are directly operated on machine level instructions. Ex int, float, pointers ete Operations performed on primitive data structures are 1) ereate (2) destroy (3) select (4) update * create : This operation is used to create new data structure. Ex: imt x; > destroy : This operation is used to remove unwanted data structures. Ex: Using delete operator! destructor function select : This operation is used to extract required data from data structure Ex: cout<
Object oriented databases, > CAD/CAM systems > Computer graphics and applications Or any three applications 2.Write a note on Polymorphism > Polymorphism is considered one of the important features of Object-Oriented Programming > ‘The word “poly” means many and “morphs” means forms, So it means many forms > The ability of an operator and function to take multiple forms is known as Polymorphism > The different types of polymorphism are operator overloading and function overloading 3) Write any four high-level languages that fallow object oriented programming approach Ans: 1)C#s 2) Cit 3) java 4) Python 4) Explain Inheritance. > Inheritance is the process by which one object can acquire and use the properties of another object The existing class is known as base elass or super class. The new class is known as derived class or sub class. ‘The derived class shares some of the properties of the base class. Therefore a code from a base class can be reused by a derived class. . rul islam vv II. FIVE MARKS QUESTIONS 1, Mention and explain any five features or basic concepts of OOP. > Class — Class is collection of data and functions. > Object- Object is a real world entity with some characteristics and behavior. > Inheritance- It is the capability of one class to inherit the properties from another class > Polymorphism. It is the ability for a message to be processed in more than one form. > Function Overloading- Two are more functions have same name but differ in the arguments or data types. 2)Explain the advantages of OOP's > Modularity based on class and object principle is followed. Code reusability to avoid code duplication. Encapsulation provides security of data from being used by non member function of class. Easier to develop complex software because inheritance helps to overcome code complexity. Object specification and implementation are separated by concept abstraction. Development time of software is reduced because creation and implementation is easy. OOP can communicate through message passing which makes description of interface outside the jem very easy vyvyvvyy SS I PUC COMPUTER SCIENCE (41) Page 20 © scanned wth omen scamer3)Explain the limitations or disadvantages of object oriented programming or Define object oriented programming. Write the limitations of object oriented programming % Object Oriented programming (OOP) is a programming paradigm that relies on the concept of classes and objects. > Itis used to structure a software program into simple, reusable pieces of code blueprints (usually called classes), which are used to create individual instances of objects. > ‘There are many object-oriented programming languages including JavaScript, C++, Java, Python. 1. OOP software is not having set standards. 2, The adaptability of flow diagrams and object oriented programming using classes and objects is a complex process. 3. To convert a real world problem into an object oriented model is difficult 4. The classes are overly generalized. 5. The size of programs developed with OOP proach 6. Since OOP programs are larger in size, the execution time for these programs is also more. 4)Mention any five application of OOP. > Computer graphic application. > ion. ind is bigger than those developed with a procedural ap- > Pattern recogn > CAD/CAM software. > Web based application. > Mobile computing, . > Data warehouse and data mining. | \ m > Object Oriented Database, ith no or ul | sla > User interface design sugh,agwi ash W 5 scitsces BSNCSt > Simulation and Modeling. > Artificial intelligence and expert system. 5) Give the difference between procedural oriented programming and object oriented programming. OOP POP TT RE ERE Tepe bina as Tea aT am Sarasa Tapio Fae TST Fa a SET ROTO as eT re ES Tana a ap ee eae! Case era Eee a aon rE ar aa aoa rail pan TT RTT ETT OT TRL SAS RO | NS ESTE Trang ae SE oases Toa Se THRONE OORT CE RTA aa ——_ I PUC COMPUTER SCIENCE (41) © scanned wth omen scamerCLASSES AND OBJECTS LTWO MARKS QUESTIONS 1) _Write the differences between class definition and class declar: ion ? Class declaration Class defination Class declaration includes informing the compiler about properties of the variable such as its name, type of value it holds and the initial value if any it takes. Class definition is basically the actual implementation and memory location of function and about memory for the variable is allocated during the definition of the variable. Memory has not been allocated during the declaration of a variable or function, class Memory has been allocated during the definition of a variable or function or class The declaration could be done multiple times either of a variable or of function. Variable or function could be defined only once. el CHAPTER - 2) Explain the different types of access specifiers ? Ans: Access specifiers define how the members (attributes and methods) of a class can be accessed. Every data member of a class is specified by three levels of access protection for hiding data and function members internal to the class. Access specifier define the scope of the data pela fish with noorul islam 2. 2 public le for class declaration 3.3 mores 3) Give the syntax and exai ‘A dass declaration specifies the representation of objects of the class and set of operations that can be applied to such objects. ‘Syntax: class class_name { private: variables declaration: Example: class addition { private: int a, b, sum; public: void getdatat ); display); I PUC COMPUTER SCIENCE (41) © scanned wth omen scamer. FIVE MARKS QUESTIONS 1) What is class definition and declaration? Write its general syntax and example > A class definition is a process of naming a class and the data variables ,and interface operation of the class. > ‘The variables declared inside a class are known as data members. > ‘The functions declared inside a class are known as member functions. > A class declaration specifies the representation of objects of the class and set of operations that can be applied to such objects. General syntax: class user_defined_name private: Member_dat Member_func Member_data; Member_functions; protected: Member_data; Member_fune tick with 00 publ orul islam Where, Key word class is used to declare a class ‘User_Defined_Name is the name of the class. Class body is enclosed in a pair of flower brackets. Class body contains the declaration of its members (data and functions) ‘There are generally three types of members namely private, public and protected. Example: class Account ( private int ace_no: char ni char ace_type| int bal_amt; void getdata(); void display(); 2) What are access specifiers? Explain any two with examples. ‘Access specifiers define the scope of data i.e., it controls the access of data and functions of a class. There ure three levels of access specifiers: > private > public > protected. —— I PUC COMPUTER SCIENCE (41) Page 23 © scanned wth omen scamerLLnL Private: ¥ private access means a member data can only be accessed by the class member function ¥ The data members or member functions declared private cannot be accessed from outside the class. The objects of the class can access the private members only through the public member functions of the class. This property is also called information hiding Y By default data members in a class are private Example: private: int x; fl ¥: publie: public access means that member can be accessed any function inside or outside the class Example: public: int width; void getdata( ); protected: ¥ The members which are declared using protected can be accessed only by the member functions, friend of the class and also the member functions derived from this class. ¥ The members cannot be accessed from outside the class ¥ The protected access specifier is similar to private acces: Example: protected: int x, y: 3) Explain member function inside the class definition with syntax and example > To define member function inside a class the function declaration within the class is replaced by actual function definition inside the class > A function defined in a class is treated as inline function > Only small functions are defined inside class definition Syntax: return_type class_name(member function i jam | type class_name( r Doe noorul \S as ==—prgtisht with int length, breadth, area; publi void get_data() //function definition { cout<<” Enter the values for Length and Breadth”; cin>>length>>breadth; } void compute( ) //funetion definition ( area = length * breadth; ) voi { cout<<" The area of rectangle display( ) //function definition I PUC COMPUTER SCIENCE (41) © scanned wth omen scamerel 4) What are the characteristics of member functions outside a class? Or Explain member function outside the class definition with syntax and example > A function declared as a member of a class is known as member function > Member functions declared within a class must be defined separately outside the class To define member function outside the class declaration, you must link the class name of the class with the name of member function. > We can do this by preceding the function name with the class name followed by two colons (::) > The two colons (::) are called scope resolution operator. > Scope resolution operator (::) is used to define the member function outside the class. > _The general form of a member function defined outside the class i Telurn_type class_name: : member_function_name( argl, arg2, ....argN) function bod; Example: class operation { private: int a, b; public: int sum(); int product( ): h int operation : : sum( ) a (arb); ) : int oper: : product() . ul islam at {¢ tish with noo r 5) Explain defining objects of a class with syntax and a programming example > An object is a real world element which is identifiable entity with some characteristics (attributes) and behavior (functions) > An object is an instance of a class. Objects are sometimes called as instance variables. > An object is normally defined in the main ( ) function. Syntax: class user_defined_name Private Public: } User_defined_name object! object2...... object: Where, User_defined_name is name of the class and object! and object... object are the objects of class TTT as I PUC COMPUTER SCIENCE (41) Page 25 © scanned wth omen scamerclass Student ivate: iclam cgfaeh with noorul 'sl@ publie: void get_data( ): void display( ); h Student $1, $2, $3: //ereation of objects Here, creates object $1, $2, and S3 for the class Student. When an object is created space is set aside for it in memory 6) Describe how objects can be used as function arguments? ‘A function can receive an object as a function argument. An object can be passed to a function in two ways: 1. Copy of entire object is passed to function ( Pass by value) 2. Only address of the object is transferred to the function (Pass by reference) Y In pass by value, copy of object is passed to the function. Y The function creates its own copy of the object and uses it. Y changes made to the object inside the function do not affect the original object. Y In pass by reference, when an address of an object is passed to the function, the function di- rectly works on the original object used in function call Y This means changes made to the object inside the function will reflect in the original object, because the function is making changes in the original object itself. Y Pass by reference is more efficient, since it requires only passing the address of the object and not the entire obje i I PUC COMPUTER SCIENCE (41) Page 26 © scanned wth omen scamerel CHAPTER 8: FUNCTION OVERLOADING 1. What is function overloading? What are the advantages of function overloat Function Overloading means two or more functions have the same name, but differ in the number of argu- ments or data types of arguments Advantages of function overloading: > Iris easier to understand the flow of information and debug. > Code Maintenance is easy > Code is executed faster. > Better understanding of the relation between the program and real-world objects. > Eliminates the use of different function names. 2. Discuss overloaded functions with example. > ‘The main factor in function overloading is a function’s argument list > C++ can distinguish overloaded functions by the number and type of arguments. > If there are two functions having the same name and different types of arguments or different number of arguments, then function overloading is invoked automatically by the compiler. > Function Overloading is also known as Compile time polymorphism Program to compute the volume of cone, cube and cylinder using aril ‘tions. #include
\ imine lish with NOO rul istam ' make n 9 int volume(int a) // Volume of Cube ( } double volume(double r, double h) // Volume of Cone { double volume(double r, int h) // Volume of Cylinder { return ata*; return (0.33*3.14¢r*r*h); return (3.14%r*r%h); ) double volume(double 1, double b, double h) //Volume of Cuboid { return (I*b*h); hi int main) { funoverload f1; cout<<*Volume of the Cube: “<
To work transparently and without any issues Restrictions: > Each function in a “set of overloaded functions” must have different arguments, 4, What is an inline function? Write a simple program for it. > An Inline function is a special type of function whose body is inserted at the place where it is called, instead of transferring the control to the function called, > The keyword inline is used to define inline function. Program to find the cube of a number using inline function: +#include
anes lislam english with nooru int x, y: x=squua coutc<' yesquat cout<<' return 0; 5. Mention the advantages and disadvantages of inline function. Advantage of inline function: > The readability of the program increases. > Ttalso saves the overhead of return call from a function. > There is no burden on the system for function calling > Very efficient code can be generated. > The speed of execution of a program increases. > The size of the object code is considerably reduced, Disadvantage of inline functio > May increase the size of the executable file. > More memory is needed > Ifused in header file, it will make your header file size large and may also make it unreadable. 6. Explain friend function and their characteristics. > A friend function is a non-member function that is a friend of a class. > The friend function is declared within a class with the prefix friend = IPUC COMPUTER SCIENCE (41) Page 28 © scanned wth omen scamershould be defined outside the class like a normal function without the prefix friend > It can access public data members like non-member functions. Syntar class class_name ; ah fe -m etiohwwitlh noorul isla ‘Example : friend void showbalance(account); Characteristics of friend functions > A friend function although not a member function, has full access rights to the private and protected members of the class, > A friend function can be called like a normal function with/without the use of any object. > Example: friendfunctionname(objectname) > They are normal external functions that are given special access privileges. » It cannot access the member variables directly and has to use an objectname.membername (Here is a membership operator). Example: object.readdata(); > The function is declared with keyword friend. But while defining friend function it does not use either keyword friend or : operator. I PUC COMPUTER SCIENCE (41) © scanned wth omen scamerCONSTRUCTOR AND DESTRUCTOR 1, What is a constructor? Give an example. Constructor is a special member function which is used to initialize the automatically, > Constructor is a special member function which is automatically nember variable of an object led when an object is created. Ex: class A { int p: public: th noorul islam } 2. What is a destructor? Write the operator which is used with a destructor. > Destructor is a special member function that destroys an object automatically. > Tilde (~) operator is used to define a destructor. 3. Mention different types of constructor. > Default constructor » Parameterized constructor > Copy constructor 4, Mention the features of default constructor. > Default constructor does not have any arguments. > For every object created, default constructor is automatically called. > All objects of a class are initialized to same set of values. 5, Mention the features of Parameterized constructor. > Itaccepts one or more arguments. > It can be overloaded. > ILis possible to initialize different objects with different values IL, Five marks questions and answers 1, Write the rules for writing a constructor function. Constructor name is same as the class name. ‘A constructor has no return value data type. The constructor should be declared in public section. A constructor is invoked automatically when objects are created. A class can have more than one constructor, but all the constructors should have the same name. > Ifa class has more than one constructor, then they differ in their signature. 2. Explain default constructor with an example. > Default constructor does not accept any arguments. > For every object created, default constructor is automatically called. > All objects of a class are initialized to same set of values > Itallocates the memory to data member of object when it is created. + _Itcannot initialize different values for different objects, ——$=5sn uU0_eeCE ep? OO IPUC COMPUTER SCIENCE (41) Page 30 VV VY © scanned wth omen scamerEx: #include
class x { void display { , couts<"a="<
Copy constructor is used to copy one object to another object } Iris used to initialize an object with the values of already existing object. > A copy constructor is invoked automatically when a new object(a2) is created and is equated to the existing object(al) in the declaration itself. xal; //al existing object x a2=al; // copy constructor To pass objects as value parameters of a function Ex: void test(x a) { } void main) { xb; test(b):// copy constructor is invoked > When an existing parameterized constructor(al) is passed as argument to the new object(a2) during declaration, then also copy constructor is invoked. > Example: x al(100,200); // parameterized constructor = IL PUC COMPUTER SCIENCE (41) Page 31 © scanned wth omen scamerEx > VV VVVYVY x a2(al); // copy constructor is invoked for object a2 with al Copy constructor is not invoked explicitly. plain destructor with syntax and example. Destructor is a member function that destroys an object automatically. Destructor is used to de-allocate all the memory that was allocated for the object by the constructor. Tilde (~) operator is used to define a destructor. Destructor name is same as the class name. There is no return value data type for destructor. The destructor should be declared in public section, ‘They take no arguments. Destructor cannot be overloaded iherited Destructor cannot be Syntax: class classname { private: // data members and methods public: classname( ); //constructor Ee vacamoe ul islam Ex class num, { private: int x; public: ‘num( )// constructor ( cout<<"In constructor:”; x=100: } void display( ) ( cout<<"Value of X="<< x; ) ~num( ) //destructor t cout<<"In destructor”, ) k void main) ( num a: adisplay( ) } Output In constructor: Value of X=100 I PUC COMPUTER SCIENCE (41) © scanned wth omen scamer5. Explain the features of Default constructors. > A class can have only one default constructor. \ 1 s| am Default constructor does not haye any arth oO Oo y u \ > > All objects ofa clase ith 0 ovr > default c fram, then C++ compiler automatically generates it in a program for’ > Itcan be explicitly written in the public section of the class. 6, Mention the features of Parameterized constructor. > Itaccepts one or more arguments. It can be overloaded. Itis possible to initialize different objects with different values, Arguments can be variables or expressions. ‘The number of arguments and data type of actual argument must ma vvvyY ch with the formal argument. SS I PUC COMPUTER SCIENCE (41) Page 33 © scanned wth omen scamerCHAPTER 10: INHERITANCE I. ONE MARK QUESTIONS AND ANSWER: 1) What is inheritance? Inheritance is the capability of one class to inherit properties from another class. 2) What is base class? It is the class whose properties are inherited by another class. 3) What is derived class? Its the class that inherits properties from base class or classes. 4) What is multiple inheritance? If a class is derived from more than one base class, it is known as multiple inheritance. 5) Is inheritance possible in C? No. 6)_Write the syntax for defining derived class. Syntax: class derived_class_name # visibility_mode base_class_name {islam "neat yigabatany ith OOTY 7) What is an abstract class: ‘An abstract class is one that is not used to create objects. It is designed only to act as a base class (10 be inherited by other classes), 8) Name any one characteristics of public vis mode The public members of a base class become public members of the derived class. IL.Two marks questions and answers : 1) Whatis virtual base class? Give an example. ‘When two or more objects are derived from a common base class, multiple copies of the base class can be prevented by making the base class as a virtual base class. This can be achieved by preceding the base class name with the keyword ‘virtual’ classA th: il public A ts class C : virtual public A {ie 2) What is visibility mode? What is its role? Visibility mode(public, private and protected) basically controls the access specifier to be for inheritable members of base class in the derived class The role of visibility modes: lias Derived Class Class [Public mode | Private mode _ | Protected mode ‘Notinherited [Not inherited | Not inherited Public Private Protected Protected Private Protected —<—<—<—— I PUC COMPUTER SCI Page 34 © scanned wth omen scamer3) How does inheritance influence the working of constructors? > If the base class constructor has parameters then it is mandatory for the derived class to have a constructor and pass the arguments to the base class. > When both the derived and base classes contains constructors, the base constructor is executed first and then the constructor in the derived class is executed. Example: class base { public: based { J /Moase class constructor i class derived : public base { public: derived’) { ) derived class constructor L II. FIVE MARKS QUESTIONS AND ANSWERS 1) Mention the advantages of inheritance. > Reusing existing code Faster development time . 1 th noorul \S Easy to maintain | hh wi Easytoextend OY) g Memory utilization in briefly the types(levels) of inheritance. ingle Inheritance: a class is derived from a single base class, itis called as single inheritance vvvyv 2) Expl > Multi level Inheritance: The classes can also be derived from the classes that are already derived. This type of inheritance is, called multilevel inheritance. Multiple Inheritance: Ifa class is derived from more than one base class. it is known as multiple inheritance. = a — + ened ciass_ + I PUC COMPUTER SCIENCE (41) Page 35 (O scanned wih nen Scanner,‘+ Hierarchical Inheritance: If a number of classes are derived from a single base class, it is called as hierarchical inheritance me ot ‘ a ‘ Geto] [Grit] [Beets] ine, nat | uo ‘+ Hybrid Inheritance: Hybrid Inheritance is combi jon of Hierarchical and Multilevel Inheritance. we ~ Hicrarchical inheritance = ~ 3) Explain single level inheritance with programming example. Ia class is derived froma single base class, itis called as single inheritance. Program to illustrate single level inheritance: #includeciostream.h> #include
#include
class base { private: int rollno; char name[ 10); pues void read| j lam oid 1 é noorul \S lish with,O No and Name “<
> rollno >> name; void display() { cout <<“ Roll No : “<< rolino <
> ml >> m2: teml+m2; } void display!) ( cout <<“ First marks =“ << ml <
The stream that supplies data to the program is known as input stream. It reads the data from the file and transfers it to the program. > The stream that receives data from the program is known as output stream. It writes the received data to the files. 2. What is significance of fstream.h header file.? fstream.h is a header file of C++ standard library which is used to implement inpuV/output operations. The {stream library predefines a set of operations for handling files related to input and output. It defines certain classes that help to perform file input and output operations. It consists of ifstream ,ofstream and {stream classes. ifstream Iris a stream class to read from files. It provides input operations for file. It inherits get( ),getline( ).read( ) seekg( ) and tellg( ) functions from. istream class ofstream | Tt is a stream class to write on files. It provides output operations for file. It inherits put( ),write( ), seekp( ) and tellp( ) functions from ostream class. stream Ieis a stream class to both read and write from/to files. It provides support for multaneous input and output operations. It inherits all the functions from istream and ostream classes. =) I PUC COMPUTER SCIENCE (41) Page 44 © scanned wth OREN Scannerds of opening file wit Ans: File can be opened in 2 ways 1) Opening file using constructor 2) Opening file using open( ) member function 1. Opening file using constructor in C++ Discuss. ‘This method is used when a single file is used with a stream. ‘@) Opening a file for output purpose only using an b)Opening a file Tor input purpose only using an ofstream fout(“result dat”) object of ofstream —class_-—aand___the | object of ‘ifstream class and constructor constructor Syntax: Syntax: ofstream ofstream_object(“file_name”); ifstream_ifstream_object(“file_name”) Example: Example: ifstream fin( “result dat”); 2. Opening file using open( ) @) Opening a file for ouput purpose only using an object of ofstream class and open() member function. b) Opening a file for input purpose only using an object of ifstream class and open( ) member function ‘Syntax: ofstream_object open(“file_name” fp open(“student di english wit fegeorul isa ifstream fp; fp open(‘“book dat”); = |. Differentiate between ifstream class and ofstream class ifstream ofstream L.Itis a stream class to read from files Litis a stream class to write on files 2 This class supports input operations 2. This class supports output operations 3.1 contains open( ) with default input mode 3.1t contains open() with default output mode ‘tinherits get( ),getline( ),read( ),seekg( ) and tellg() functions from istream 40 It inherits putO,writeQ.seekp() and tellp0) function from ostream ‘S.Example: ifstream fb; fh open(“text dat”) 5.Example: ofstream fb; fh open(“text dat”) Differentiate between read( ) and write( ) with example. read() write() 1. It belongs to the class ifstream Lit belongs to the class ofstream 2.It reads binary data from a file. 2. It writes binary data to a file. ifstream fin(“std.dat” ios:-binary); fin.read((char*)&s,sizeof(s)): 3.Syntax: 3.Syntax: fout.write((char —*) _ &variable, fin.read (char*)&-variable,sizeof{variable)); sizeofivariable)) FExample 4-Example student s; student s; ofstream fout(‘“std dat fout.write((char*)&s I PUC COMPUTER SCH © scanned wth omen scamer6. Differentiate between get( ) and getline( ). get) getline() TW reads a single character from the associated stream. T.Itis used to read a whole line of text atiglish witht 2.Syntax: ifstream_object.get(ch); 2. Syntax: _ifstream_qbjeet.getiiny ze): ‘Example: Examp] u char cha cure ifstream fin( “am fin; fin.get(ch); fin,getline(book.size): Explain file modes. File mode parameter Meaning, ‘Stream Type jossapp ‘Append to end of file ofstream jossin Open file Tor reading only iistream Tos::out Open file for writing only ofstream josate Open file for updation and move the file | ifstream,ofsweam pointer to the end of file Tossibinary Opening a binary file iistream,ofstream fstream fin(“text.dat”,ios::in), fstream f file.open(“example bin” jos: outlios::applios’ binary) Open the file “example bin” in binary mode to add data 8. Differentiate between :in and ios Stream foui(“text dat" jos: out), Open text dat in output mode ‘Open text dat in input mode ios::in jos:zout Lit belongs to ifstream class LI belongs to ofstream class 2.It opens file for reading only 2.Itopens file for writing only 3.Example: {stream fin(‘text dat” ios::in), Open text.dat in input mode S.Example: stream fout(“text dat” jos: out), ‘open text.dat in output mode © scanned wth omen scamer
You might also like
II Pu Physics Question Bank 2024-25
PDF
No ratings yet
II Pu Physics Question Bank 2024-25
129 pages
Computer Science Passing Package
PDF
86% (22)
Computer Science Passing Package
69 pages
Chapter-1: Typical Configuration of Computer: (1mark - 1Q, 3 Marks - 1Q)
PDF
No ratings yet
Chapter-1: Typical Configuration of Computer: (1mark - 1Q, 3 Marks - 1Q)
3 pages
Computer Science Passing Package-1
PDF
No ratings yet
Computer Science Passing Package-1
96 pages
II Puc CS 1st and 4th Chapters Notes
PDF
No ratings yet
II Puc CS 1st and 4th Chapters Notes
17 pages
2 Puc Computer Science Viva Questions
PDF
No ratings yet
2 Puc Computer Science Viva Questions
11 pages
II PUC Computer Science
PDF
No ratings yet
II PUC Computer Science
480 pages
Computer Science 12nd Puc Chapter 15
PDF
100% (1)
Computer Science 12nd Puc Chapter 15
3 pages
Prep Udupi Paper PU II Year 2024
PDF
No ratings yet
Prep Udupi Paper PU II Year 2024
16 pages
MCQs CS ALL2023-24
PDF
100% (1)
MCQs CS ALL2023-24
29 pages
2nd PUC Computer Science - Score 65+ With MCQ Topics - YouTube
PDF
No ratings yet
2nd PUC Computer Science - Score 65+ With MCQ Topics - YouTube
8 pages
2nd PUC Computer Science Paper 3
PDF
No ratings yet
2nd PUC Computer Science Paper 3
2 pages
Cs All District Pre QP 2025
PDF
No ratings yet
Cs All District Pre QP 2025
52 pages
2nd Puc Physics State Level Preparatory Exam Question Paper 2023
PDF
No ratings yet
2nd Puc Physics State Level Preparatory Exam Question Paper 2023
3 pages
(1M, 2M, 3M) Typical Configuration OF Computer System. 1 Marks
PDF
No ratings yet
(1M, 2M, 3M) Typical Configuration OF Computer System. 1 Marks
11 pages
5 Marks Questions
PDF
100% (2)
5 Marks Questions
4 pages
Chapter 5 Review of C++
PDF
No ratings yet
Chapter 5 Review of C++
47 pages
Karnataka I PUC Computer Science Sample Question Paper 1 PDF
PDF
No ratings yet
Karnataka I PUC Computer Science Sample Question Paper 1 PDF
2 pages
Ii Puc List of Formulas
PDF
No ratings yet
Ii Puc List of Formulas
6 pages
Numerical Problems (Second Year Physics)
PDF
No ratings yet
Numerical Problems (Second Year Physics)
46 pages
2nd Puc English State Level Preparatory Exam Question Paper 2023
PDF
No ratings yet
2nd Puc English State Level Preparatory Exam Question Paper 2023
4 pages
2nd Puc Maths Pocket Marks Package Eng Version 2019-20 by Anand Kabbur
PDF
No ratings yet
2nd Puc Maths Pocket Marks Package Eng Version 2019-20 by Anand Kabbur
31 pages
PQP 01 Puc II Maths 2024
PDF
No ratings yet
PQP 01 Puc II Maths 2024
8 pages
2nd Pu Chemistry Important Concept
PDF
100% (1)
2nd Pu Chemistry Important Concept
39 pages
2nd Puc Chemistory State Level Preparatory Exam Question Paper 2023
PDF
No ratings yet
2nd Puc Chemistory State Level Preparatory Exam Question Paper 2023
3 pages
Physics Passing Package - 2024
PDF
No ratings yet
Physics Passing Package - 2024
16 pages
PUC II CS Previous Year QPs
PDF
No ratings yet
PUC II CS Previous Year QPs
178 pages
2 Boolean Algebra: 2 Marks Questions
PDF
No ratings yet
2 Boolean Algebra: 2 Marks Questions
4 pages
PUC II Phy Imp Fix Questions Also Previous Year Questions
PDF
No ratings yet
PUC II Phy Imp Fix Questions Also Previous Year Questions
30 pages
II PU MCQ Chapterwise23
PDF
100% (1)
II PU MCQ Chapterwise23
14 pages
Model Question Papers PDF
PDF
No ratings yet
Model Question Papers PDF
43 pages
2nd Puc Computer Science Question Papers-2006 To 2011
PDF
No ratings yet
2nd Puc Computer Science Question Papers-2006 To 2011
32 pages
2nd-Puc-Lab-Manual-Section B and C-1
PDF
No ratings yet
2nd-Puc-Lab-Manual-Section B and C-1
13 pages
II Pu Cs Mcq Chapter-1,7,8,9,10,14
PDF
100% (1)
II Pu Cs Mcq Chapter-1,7,8,9,10,14
25 pages
I PUC Cs Important Questions 2015
PDF
No ratings yet
I PUC Cs Important Questions 2015
10 pages
I PUC Computer Science
PDF
No ratings yet
I PUC Computer Science
2 pages
II PU Lab Programs 2024-25 Final
PDF
No ratings yet
II PU Lab Programs 2024-25 Final
24 pages
II PUC PHYSICS - SPECIAL DRIVE (CH - 02) - GSGP's - PRINT
PDF
100% (1)
II PUC PHYSICS - SPECIAL DRIVE (CH - 02) - GSGP's - PRINT
44 pages
2nd PUC Labmanual - Final
PDF
No ratings yet
2nd PUC Labmanual - Final
58 pages
Class XI - Computer PUC I Q & A
PDF
No ratings yet
Class XI - Computer PUC I Q & A
223 pages
MLL Study Material PDF
PDF
100% (1)
MLL Study Material PDF
25 pages
2ND PUC COMPUTER SCIENCE NOTES PDF
PDF
No ratings yet
2ND PUC COMPUTER SCIENCE NOTES PDF
8 pages
Chapterwise-Examinations Question II Puc (2014 To 2022) PDF
PDF
0% (1)
Chapterwise-Examinations Question II Puc (2014 To 2022) PDF
52 pages
Maths Materials PDF
PDF
No ratings yet
Maths Materials PDF
16 pages
Che Preparatory
PDF
100% (1)
Che Preparatory
4 pages
Xii Board Passing Package 2022
PDF
100% (1)
Xii Board Passing Package 2022
40 pages
Computer Science 2002 Question Paper
PDF
No ratings yet
Computer Science 2002 Question Paper
5 pages
Apj II Pu Maths Preparatory Papers
PDF
No ratings yet
Apj II Pu Maths Preparatory Papers
13 pages
11 Societal impact
PDF
No ratings yet
11 Societal impact
5 pages
Computer Science Questions
PDF
No ratings yet
Computer Science Questions
50 pages
II PUC-Previous Year PUC Board Question Papers
PDF
No ratings yet
II PUC-Previous Year PUC Board Question Papers
27 pages
Chem All District Pre QP 2025
PDF
No ratings yet
Chem All District Pre QP 2025
145 pages
2nd Puc Computer Science Notes PDF (1 Mark Questions and Answers) - 2nd Puc Computer Science
PDF
No ratings yet
2nd Puc Computer Science Notes PDF (1 Mark Questions and Answers) - 2nd Puc Computer Science
15 pages
Kcet 2018 Answer Keys by Expert Coaching Classes PDF
PDF
No ratings yet
Kcet 2018 Answer Keys by Expert Coaching Classes PDF
41 pages
2nd PUC Computer Science - Most Important Questions - YouTube
PDF
No ratings yet
2nd PUC Computer Science - Most Important Questions - YouTube
3 pages
Bio All District Pre QP 2025
PDF
No ratings yet
Bio All District Pre QP 2025
133 pages
Kcet Physics 2015
PDF
100% (1)
Kcet Physics 2015
12 pages
Ii Puc Computer Science Past Board Papers Chapter Wise
PDF
No ratings yet
Ii Puc Computer Science Past Board Papers Chapter Wise
44 pages
CS Computer Science Passing Notes
PDF
No ratings yet
CS Computer Science Passing Notes
69 pages
CS - PUC-II - All Chapter'S - Question Bank Final
PDF
No ratings yet
CS - PUC-II - All Chapter'S - Question Bank Final
87 pages