Eduniv 2
Eduniv 2
Study Material
Book Back One words
1. First generation computers used Vacuum tubes
2. Name the volatile memory RAM
3. Identify the output device Monitor
4. Identify the input device Mouse
5. … Plotter … Output device is used for printing building plan, flex board, etc.
6. In ATM machines, which one of the following is used to Touch Screen
7. When a system restarts which type of booting is used. Warm booting
8. Expand POST Power on Self Test
9. Which one of the following is the main memory? RAM
10. Which generation of computer used IC’s? Third
1. What is a Computer?
A computer is an electronic device that manipulates information, or data. It
has the ability to store, retrieve, and process data. Computer works faster than
human being and given the values more accuracy and reliable.
Optical mouse is less sensitive towards Laser Mouse is highly sensitive and able
surface. to work on any hard surface.
• Input unit : Input unit is used to feed any form of data to the computer,
which can be stored in the memory unit for further processing.
• Central Processing Unit : CPU is the major component which interprets
and executes soft- ware instructions. It also control the operation of all
other components such as memory, input and output units.
• Arithmetic and Logic Unit : The ALU is a part of the CPU where
various computing functions are performed on data. The ALU performs
arithmetic operations such as addition, subtraction, multiplication, division
and logical operations.
• Control Unit : The control unit controls the flow of data between the CPU,
memory and I/o devices. It also controls the entire operation of a computer.
• Output Unit : An output unit is any hardware component that conveys
information to users in an understandable form. Example : Monitor, Printer
etc.
• Memory Unit : The Memory Unit is of two types which are primary
memory and secondary memory. The primary memory is used to temporarily
store the programs and data when the instructions are ready to execute. The
secondary memory is used to store the data permanently. The Primary
Memory is volatile, that is, the content is lost when the power supply is
switched off. The Random Access Memory (RAM) is an example of a main
memory. The Secondary memory is non volatile, that is, the content is
available even after the power supply is switched off. Hard disk, CD-ROM
and DVD ROM are examples of secondary memory.
3 .Explain the following : a. Inkjet Printer b. Multi media projector c. Bar code /
QR code Reader
Ans.
Inkjet Printers:
• Inkjet Printers use colour cartridges which combined Magenta, Yellow and
Cyan inks to create color tones. A black cartridge is also used for monochrome output.
Inkjet printers work by spraying ionised ink at a sheet of paper.
• They use the technology of firing ink by heating it so that it explodes
towards the paper in bubbles or by using piezoelectricity in which tiny electric currents
controlled by electronic circuits are used inside the printer to spread ink in jet speed.
• An Inkjet printer can spread millions of dots of ink at the paper every single
second.
Multimedia Projectors:
• Multimedia projectors are used to produce computer output on a big screen.
• These are used to display presentations in meeting halls or in classrooms.
Bar Code / QR Code Reader:
• A Bar code is a pattern printed in lines of different thickness. The Bar code
reader scans the information on the bar codes transmits to the Computer for
further processing.
• The system gives fast and error free entry of information into the computer.
QR (Quick response) Code:
The QR code is the two dimension bar code which can be read by a
camera and processed to interpret the image.
***************************
MAHATMA
Computer Science / computer Application
Class XI Chapter 2- Number System
One Word
1. Define data
➢ The term data comes from the word datum, which means a raw fact.
➢ The data is a fact about people, places or some objects.
➢ Data is defined as an un- processed collection of raw facts,
➢ suitable for communication, interpretation or processing.
➢ It is an input of the computer.
➢ It will not giving any meaningful message. Ex. 134, 16 „Kavitha‟, „C‟
3marks:
Step 1: Multiply the decimal fraction by 2 and note the integer part. The integer part is
either 0 or 1.
Step 2: Discard the integer part of the previous product. Multiply the fractional part of
the previous product by 2. Repeat Step 1 until the same fraction repeats or terminates (0).
Step 3: The resulting integer part forms a sequence of 0s and 1s that become the
binary equivalent of decimal fraction.
Step 4: The final answer is to be written from first integer part obtained till the last integer
part obtained.
Write the integer parts from top to bottom to obtain the equivalent fractional binary number
1. The term data comes from the word datum which means a raw fact
2. The data is a fact about people, places or some objects.
3. Computer handles data in the form of „0‟(Zero) and „1‟ (One).
4. A bit is the short form of Binary digit which can be „0‟ or „1‟.
5.Bit is the basic unit of data in computers.
6. A nibble is a collection of 4 bits
7. A collection of 8 bits is called Byte
8. A byte is considered as the basic unit of measuring the memory size in the
Computer
9. Word length refers to the number of bits processed by a Computer‟s CPU
10. Computer memory (Main Memory and Secondary Storage)is normally
represented in terms of KiloByte (KB) or MegaByte (MB). 11.In decimal system,
1 Kilo represents 1000
12.In binary system, 1 KiloByte represents 1024 bytes
13.Yotta =2^80,Zetta=2^70, Exa=2^60, Peta=2^50,Tera=2^40,Giga=2^30
Mega=2^20,Kilo=2^10
14. Bytes are used to represent characters in a text
15. ASCII stands for American Standard Code for Information Interchange
16. The ASCII value for (blank space) is 32
17.ASCII value of numeric 0 is 48
18.ASCII values for lower case alphabets is from 97 to 122 19.ASCII
values for the upper case alphabets is 65 to 90
20. A numbering system is a way of representing numbers 21.The most
commonly used numbering system in real life is Decimal number system
22. Each number system is uniquely identified by its base value or radix
23. Radix or base is thecount of number of digits in each number system
24. In the positional number system, each decimal digit is weighted relative to its
position in the number
25. The numbers in the binary system are represented to the base 2
26. The left most bit in the binary number is called as the Most Significant Bit
27. The right most bit is the Least Significant Bit
28. Octal number system uses 8 digits
29. A hexadecimal number is represented using base 16
30. Which number system is used to represent data in a more compact
manner – Hexadecimal Number system
31. To convert Decimal to Binary “Repeated Division by 2” method can be used.
32. To convert Decimal to Octal, “Repeated Division by 8” method can be used.
33. To convert Decimal to Hexadecimal, “Repeated division by 16” method can
be used
34. The method of repeated multiplication by 2 has to be used to convert
Decimal Fraction to Binary Fraction
35. Computers can handle both positive (unsigned) and negative (signed) numbers.
36. The simplest method to represent negative binary numbers is called
Signed Magnitude
37. In signed magnitude method, the left most bit is Most Significant Bit
(MSB), is called sign bit or parity bit
38. In signed binary representation, the left most bit is considered as sign bit
39. 1‟s Complement representation is an easier approach to represent
signed numbers
40. BCD – Binary Coded Decimal
41. EBCDIC – Extended Binary Coded Decimal Interchange Code
42. ASCII – American Standard Code for Information Interchange
43. ISCII - Indian Standard Code for Information
Interchange 44.BCD can handle 64 characters.
45. Most popular encoding system recognized by United States - ASCII
46. ASCII can handle 128 characters.
47. The new edition (version) ASCII -8 can handle 256 characters
48. The ASCII code equivalent to the uppercase letter „A‟ is 65
49.EBCDIC coding system is formulated by International Business
Machine(IBM)
50. EBCDIC can handle 256 characters.
51. Indian Standard Code for Information Interchange is a 8-bit coding system
52.ISCII was formulated in the year 1986-88 and recognized by Bureau of
Indian Standards (BIS)
53. English and European Languages alone can be handled by ASCII
54. Unicode was generated to handle all the coding system of Universal
languages
55. Unicode is a 16 bit code and can handle 65536 characters
56. Unicode scheme is denoted by hexadecimal number
***********************************************
LESSON 3 Computer Organization
Study Material’s
Oneword:
1. Which of the following is sadi to be the brain of a computer? Microprocessor
2. Which of the following is not the part of a microprocessor unit? Cache memory
3. How many bits constitute a word? determined by the processor used.
4. Which of the following device identifies the location when address is placed in the
memory address register? decoder
5. Which of the following is a CISC processor? Pentium III
6. Which is the fastest memory? Cache memory
7. How many memory locations are identified by a processor with 8 bits address bus at a
time? 256
8.What is the capacity of 12cm diameter DVD with single sided and single layer? 4.7 GB
9.What is the smallest size of data represented in a CD? pits
10. Display devices are connected to the computer through. VGA connector
2. What is an instruction?
A command which is given to a computer to perform an operation on data is called
an instruction.
4. What is HDMI?
High-Definition Multimedia Interface is an audio/video interface which transfers the
compressed video and audio data from video controller, to a compatible computer monitor,
LCD projector, digital television etc..
CD DVD
▪ Expansion is Compact-Disc. ▪ Expansion is Digital
▪ A standard CD can store about Versatile Disc.
700 MB of Data. ▪ A standard DVD can hold
▪ CD players cannot play DVDs. 4.7 GB of Data.
▪ It stores up to 80 min of audio. ▪ DVD players can play
CDs.
▪ It can range from 4.7 GB to
17.08
GB.
Flash EEPROM
Memory
▪ Faster in performance. ▪ Slower in performance.
▪ Flash uses the slower NAND ▪ EEPROM uses the faster NOR
gate. gate.
▪ |Using flash, access and erase ▪ Using EEPROM, access and
data in block-wise. erase data only byte-wise or
▪ Storage capacity can range byte at a time.
from a GB to hundred of GB. ▪ Storage capacity can range
from a kilobytes to couple of
megabytes.
a) Clock Speed
Every microprocessor has an internal clock that regulates the speed at
which it executes instructions. The speed at which the microprocessor executes
instructions is called the clock speed. Clock speed is measured in MHz (Mega
Hertz) or in GHz (Giga Hertz).
b) Instruction Set
A command which is given to a computer to perform an
operation on data is called an instruction. Basic set of machine level
instructions that a microprocessor is designed to execute is called as an
instruction set. This instruction set carries out the following types of
operations:
• Data transfer
• Arithmetic operations
• Logical operations
• Control flow
• Input/output
c) Word Size
The number of bits that can be processed by a processor in a single
instruction is called its word size.
Word size determines the amount of RAM that can be accessed by a
microprocessor at one time and the total number of pins on the microprocessor.
Total number of input and output pins in turn determines the architecture
of the microprocessor.
2. How the read and write operations are performed by a processor? Explain.
i. The Central Processing Unit (CPU) has a Memory Data Register (MDR)
and a Memory Address Register (MAR).
ii. The Memory Data Register (MDR) keeps the data which is transferred
between the Memory and the CPU. The Program Counter (PC) is a special
register in the CPU which always keeps the address of the next instruction to
be executed.
iii. The Arithmetic and Logic unit of CPU places the address of the memory
to be fetched,
into the Memory Address Register.
iv. A bus is a collection of wires used for communication between the
internal components of a computer.
v. The address bus is used to point a memory location. A decoder, a digital
circuit is used to point to the specific memory location where the word can be
located.
vi. The address register is connected with the address bus, which provides
the address of the instruction. A data bus is used to transfer data between
the memory and the CPU.
vii. The data bus is bidirectional and the address bus is unidirectional. The
control bus controls both read and write operations.
Viii The read operation fetches data from memory and transfer to MDR. A
single control line performs two operations like Read/Write using 1 or 0.
IX. Also , the write operation transfers data from the MDR to memory.
3. Arrange the memory devices in ascending order based on the access time. –
Explain (or) Explain the types of Secondary Storage devices.
• CD / DVD Blu-Ray
• Flash Drives
• Cache Memory
Compact Disc (CD)
A CD or CD-ROM is made from 1.2 millimeters thick, polycarbonate
plastic material. A thin layer of aluminum or gold is applied to the surface. CD
data is represented as tiny indentations known as "pits", encoded in a spiral
track molded into the top of the polycarbonate layer. The areas between pits
are known as "lands". A motor within the CD player rotates the disk. The
capacity of an ordinary CDROM is 700MB.
DVD (Digital Versatile Disc or Digital Video Disc)
A DVD is an optical disc capable of storing up to 4.7 GB of data, more
than six times what a CD can hold. DVDs are often used to store movies at a
better quality. Like CDs, DVDs are read with a laser.
The disc can have one or two sides, and one or two layers of data per side; the
number of sides and layers determines how much it can hold. A 12 cm diameter
disc with single sided, single layer has 4.7 GB capacity, whereas the single sided,
double layer has 8.5 GB capacity. The 8 cm DVD has 1.5 GB capacity. The
capacity of a DVD-ROM can be visually determined by noting the number of
data sides of the disc. Double-layered sides are usually gold-colored, while
single-layered sides are usually silver-colored, like a CD.
Blu-Ray Disc
Blu-Ray Disc is a high-density optical disc similar to DVD. Blu-ray is the
type of disc used for PlayStation games and for playing High-Definition (HD)
movies. A double layer Blu-Ray disc can store up to 50GB (gigabytes) of data.
This is more than 5 times the capacity of a DVD, and above 70 times of a CD.
The format was developed to enable recording, rewriting and playback of high-
definition video, as well as storing large amount of data. DVD uses a red laser to
read and write data. But, Blu-ray uses a blue-violet laser to write. Hence, it is
called as Blu-Ray.
Hard Disk
Hard disk is a magnetic disk on which you can store data. The hard disk
has the stacked arrangement of disks accessed by a pair of heads for each of the
disks. The hard disks come with a single or double sided disk.
Flash Memory
Flash memory is an electronic (solid-state) non-volatile computer storage
medium that can be electrically erased and reprogrammed. They are either
EEPROM or EPROM. Examples for Flash memories are pen-drives, memory
cards etc. Flash memories can be used in personal computers, Personal Digital
Assistants (PDA), digital audio players, digital cameras and mobile phones.
Flash memory offers fast access times. The time taken to read or write a
character in memory is called access time. The capacity of the flash memories
vary from 1 Gigabytes (GB) to 2 Terabytes (TB).
Cache Memory
The cache memory is a very high speed and expensive memory, which is
used to speed up the memory retrieval process. Due to its higher cost, the CPU
comes with a smaller size of cache memory compared with the size of the main
memory. Without cache memory, every time the CPU requests the data, it has to
be fetched from the main memory which will consume more time. The idea of
introducing a cache is that, this extremely fast memory would store data that is
frequently accessed and if possible, the data that is closer to it. This helps to
achieve the fast response time. Where response Time, (Access Time) refers to
how quickly the memory can respond to a read / write request.
****************************
MAHATMA
CHAPTER - 4
THEORETICAL CONCEPTS OF OPERATING SYSTEM
Class XI Computer Science
_______________________________________________________________________________________
Part I
1) Operating system is a
A) Application Software B) Hardware C) System Software D) Component
2) Identify the usage of Operating Systems
A) Easy interaction between the human and computer
B) Controlling input & output Devices
C) Managing use of main memory
D) All the above
3) Which of the following is not a function of an Operating System?
A) Process Management B) Memory Management
C) Security management D) Compiler Environment
4) Which of the following OS is a commercially licensed Operating system?
A) Windows B) UBUNTU C) FEDORA D) REDHAT
5) Which of the following Operating systems support Mobile Devices?
A) Windows 7 B) Linux C) BOSS D) iOS
6) File Management manages
A) Files B) Folders C) Directory systems D) All the Above
7) Interactive Operating System provides
A) Graphics User Interface (GUI) B) Data Distribution
C) Security Management D) Real Time Processing
8) An Example for Single task Operating System
A) Linux B) Windows
C) MS-DOS D) UNIX
9) The File Management system used by Linux is
A) Ext2 B) NTFS C) FAT D) NFTS
Part II
1) List any two uses of Operating System?
to ensure that a computer can be used
to extract what the user wants it do.
Easy interaction between the users and computers.
Starting computer operation automatically when power is turned on (Booting).
Controlling Input and Output Devices
Manage the utilization of main memory.
Providing security to user programs.
2) What is the multi-user Operating system?
It is used in computers and laptops that allow same data and applications
to be accessed by multiple users at the same time.
The users can also communicate with each other. Windows, Linux and
UNIX are examples for multi-user Operating System
3) What is a GUI?
GUI stands for Graphical User Interface
The GUI is a window based system with a pointing device to direct I/O,
choose from menus, and make selections and a keyboard to enter text.
Its vibrant color’s attract the user very easily.
4) What are the security management features available in Operating System?
The Operating System provides three levels of securities to the user end. They are
(1) File access level
(2) System level
(3) Network level
In order to access the files created by other people, you should have the
Access permission. Permissions can either be granted by the creator of the file
or by the administrator of the system.
System level security is offered by the password in a multi-user environment.
Both windows and Linux offer the password facility.
Network security is an indefinable one. So people from all over the world try
to provide such a security.
5) What is multi-processing?
This is a one of the features of Operating System.
It has two or more processors for a single running process (job).
Processing takes place in parallel is known a parallel processing.
Since the execution takes place in parallel, this feature is used for high
speed execution which increases the power of computing.
PART III
Time-Sharing Operating
System
Advantages Disadvantages
It allows execution of multiple tasks or
Problem of Reliability
processes concurrently
Questions of security and integrity of
Quick Response
uses programs and data
Avoids duplication of software Problem of data communication
Reduces CPU idle time Various processes after a time is elapsed.
The Distributed Operating System is used to access shared data and files that
reside in any machine around the world. The user can handle the data from different
locations.
The users can access as if it is available on their own computer.
2) List out the points to be noted while creating a user interface for an
Operating System
User interface is one of the significant features in Operating System. The only way
that user can make interaction with a computer. This is a main reason for key
success of GUI (Graphical User Interface) based Operating System. The GUI is a
window based system with a pointing device to direct I/O, choose from menus,
make selections and a keyboard to enter text. Its vibrant colours attract the user
very easily.
Now Linux distribution is also available as GUI based Operating System. The
following points are considered when User Interface is designed for an application.
1. The user interface should enable the user to retain this expertise for a longer
time.
2. The user interface should also satisfy the customer based on their needs.
3. The user interface should save user’s precious time.
4. The ultimate aim of any product is to satisfy the customer. The User Interface is
also to satisfy the customer.
5. The user interface should reduce number of errors committed by the user
3) Explain the Process Management Algorithms in Operating System
Process management is function that includes creating and deleting processes
(program) and providing mechanisms for processes to communicate and
synchronize with each other.
The following algorithms are mainly used to allocate the job (process) to the
processor.
1. FIFO
2. SJF
3. Round Robin
4. Based on Priority
Technically, the process that enters the queue first is executed first by the CPU, followed
by the next and so on. The processes are executed in the order of the queue (row).
Based On Priority
The given job (process) is assigned based on a Priority. The job which has higher
priority is more important than other jobs. Take two jobs A and B. Let the priority of A
be 5 and priority B be 7.
Job B is assigned to the processor before job A.
MAHATMA
Computer Science
Class XI
___________________________________________________________________________
2marks:
1. What are the different Operating Systems used in computer?
2. What is a GUI?
3. List any two uses of Operating System?
4. What is the multi-user Operating system?
5. What is multi-processing?
3marks:
1. List Out the Key features of Operating System
5marks:
1. List out the points to be noted while creating a user interface for an Operating
System
MAHATMA
Computer Science
Class XI
___________________________________________________________________________
2marks:
1. What are the security management features available in Operating System?
3marks:
1. Write a note on multi-processing
2. What are the advantages and disadvantages of Time-sharing features?
5marks:
1. Explain the Process Management Algorithms in Operating System
2. Explain the concept of a Distributed Operating System.
6
Lesson 5 –Working with typical Operating System
Book Back Question and Answers
One Word
1. From the options given below, choose the operations managed by the operating
system.
a. Memory b. Processes c. Disks and I/O devices d. All of these
2. Which is the default folder for many Windows Application to save your file?
a. My Document b. My Picture c. Documents and Settings d. My Computer
3. Under which of the following OS the option Shift+Delete – permanently deletes a file or
folder?
a. Windows 7 b. Windows 8 c. Windows 10 d. All of the OS
4. What the meaning of “Hibernate” in Windows XP/ Windows7?
a. Restart the Computer in safe mode
b. Restart the Computer in Hibernate mode
c. Shutdown the Computer terminating all the running applications.
d. Shutdown the Computer without closing the running application.
5. The shortcut key used to rename a file in windows
a. F2 b.F4 c.F5 d. F6
Answer the following( 2 mark)
1. what is known as Multitasking?
SECTION-C
Short Answers
SECTION – D
Explain in detail
1. Explain the versions of Windows Operating System.
2. Explain the different ways of finding a file or Folder
To find a file or folder:
1. Click the Start button, the search box appears at the bottom of the start
menu.
2. Type the name of the file or the folder you want to search. Even if you give
the part of the file or folder name, it will display the list of files or folders
starting with the specified name.
3. The files or the folders with the specified names will appear, if you click
that file, it will directly open that file or the folder.
4. There is another option called “See more results” which appears above the
search box.
5. If you click it, it will lead you to a Search Results dialog box where you can
click and open that file or the folder
**********************************************************************
UNIT II ALGORITHMIC PROBLEM SOLVING
CHAPTER 6
SPECIFICATION AND ABSTRACTION
PART I Choose the Best Answer
1. Which of the following activities is algorithmic in nature?
(a) Assemble a bicycle. (b) Describe a bicycle.
(c) Label the parts of a bicycle. (d) Explain how a bicycle works.
2. Which of the following activities is not algorithmic in nature?
a)Multiply two numbers. (b) Draw a kolam.
(c) Walk in the park. (d) Braid the hair
3. Omitting details inessential to the task and representing only the essential
features of the task is known as
a. specification (b) abstraction (c) composition (d) decomposition
4. Stating the input property and the as :-output relation a problem is known
a. specification (b) statement (c) algorithm (d) definition
5. Ensuring the input-output relation is
a. the responsibility of the algorithm and the right of the user.
b. the responsibility of the user and the right of the algorithm.
c. the responsibility of the algorithm but not the right of the user.
d. the responsibility of both the user and the algorithm.
6. If i = 5 before the assignment i := i-1 after the assignment, the
value of i is (a) 5 (b) 4 (c) 3 (d)
2
7. If 0 < i before the assignment i := i-1 after the assignment, we can
conclude that
(a) 0 < i (b) 0 ≤ i (c) i = 0 (d) 0 ≥ i
ALGORITHM PROCES
S
An algorithm is a step-by-step sequence
An instruction describes an action
of statements to solve a problem
When the instructions are executed, a
As an algorithm is executed, a process
process
evolves which solves the problem. evolves, which accomplishes the
intended task or solves the given
problem
3. Specify a function to find the minimum of two numbers.
Minimum(A,B)
- - inputs: A an B are integers (or) Real numbers
- - Outputs: A is minimum such that (A<B)
(or) B is minimum such that (B<A)
3. What is abstraction?
A problem can involve a lot of details. Several of these details are
unnecessary for solving the problem. Only a few details are essential.
Abstraction is the process of hiding or ignoring the details irrelevant to the
task so as to model a problem only by its essential features.
Home Work
3marks:
5Marks:
1. Suppose u, v = 10, 5 before the assignment. What are the values of u and v after the sequenceof
assignments?
1 u := v
2 v := u
(a) u, v = 5 ,5 (b) u, v = 5 ,10 (c) u, v = 10 ,5 (d) u, v = 10 ,10
2. Which of the following properties is true after the assignment (at line 3?
1 – i,j= 0,0
2 i, j := i+1, j-1
3 -- ?
(a) i+j >0 (b) i+j < 0 (c) i+j =0 (d) i = j
(a) (1) only (b) (2) only (c) both (1) and (2) (d) neither (1) nor (2)
6. How many times the loop is iterated?
i := 0
while i ≠ 5
i := i + 1
(a) 4 (b) 5 (c) 6 (d) 0
Part II
1. Distinguish between a condition and a statement.
CONDITION STATEMENT
Condition is the Checking process of either True
Processing the condition
/ False.
A condition is contained in a diamond shaped A statement is contained in a rectangular box
box with two outgoing arrows, labeled true and with a single outgoing arrow, which points to the
false. box to be executed next.
EX: a>b EX: Print a (a-is a Biggest value)
Start
Stop
3. Both conditional statement and iterative statement have a condition and a statement. How
do they differ?
Conditional statement is executed only if the condition is true. Otherwise nothing is done.
In refinement, starting at a high level, each statement is repeatedly expanded into more detailed
statements in the subsequent levels
Part III
Pseudo code :
1. If C
2. S1
3. ELSE
4. S2
Default statement
(1) n + n
double(n)
- - Input: n is a real number or an integer, n>0
- - Output: y is a real number or an integer such that y = n + n
(2) 2 x n
Double(n)
Part IV
1. Exchange the contents: Given two glasses marked A and B. Glass A is full of apple drink and glass B is
full of grape drink. Write the specification for exchanging the contents of glasses A and B, and write a
sequence of assignments to satisfy the specification.
Solution:
drink( A, B )
-- inputs : A, B where A is Apple drink, B is grape drink
-- outputs : A (grape Drink), B ( apple drink)
t :=A;
A:=B;
B:=t.
2. Circulate the contents: Write the specification and construct an algorithm to circulate the contents of the
variables A, B and C as shown below: The arrows indicate that B gets the value of A, C gets the value of B
and A gets the value of C.
Solution:
Circulate ( A, B, C )
--Inputs : A, B, C are real numbers or an integers, A≠0, B≠0, C≠0
--Outputs :
B:=A
C:=B
A:=C
Pseudo code:
1. Start
2. Read A,B,C
3. B=A
4. C=B
5. A=C
6. Print A,B,C
7. End
3. Decanting problem. You are given three bottles of capacities 5, 8, and 3 litres. The 8L
bottle is filled with oil, while the other two are empty. Divide the oil in 8L bottle into
two equal quantities. Represent the state of the process by appropriate variables.
What are the initial and final states of the process? Model the decanting of oil from
one bottle to another by assignment. Write a sequence of assignments to achieve the
final state.
Answer:
(a)
Let a, b, c be the variables whose maximum value are 8L, 5L and 3L respectively.
Initial State:
a, b, c: = 8, 0, 0
Final State:
a, b, c: = 4, 4, 0
Specifications:
1. decant
2. – – inputs: a, b, c : = 8, 0, 0
3. – – outputs: a, b, c : = 4, 4, 0
Algorithm:
Let us assume that a: = b denote oil in b is poured into a bottle until either “a” is
full or “b” becomes empty.
1. decant (a, b, c)
2. – – a, b, c : = 8, 0, 0
3. b : = a
4. – – a, b, c : = 3, 5, 0
5. c : = b
6. – – a, b, c : = 3, 2, 3
7. a : = c
8. – – a, b, c : = 6, 2, 0
9. c : = b
10. – – a, b, c : = 6, 0, 2
11. b : = a
12. – – a, b, c : = 1, 5, 2
13. c : = b
14. – – a, b, c : = 1, 4, 3
15. a : = c
16. – – a, b, c: = 4, 4, 0
SECTION-B
1. What is an invariant?
a. An expression involving variables, which remains
unchanged by an assignment.
3. Does testing the loop condition affect the loop invariant? Why?
No. It does not affect the loop invariant. Because a loop invariant is true
• at the start of the loop
• at the start of each iteration
• at the end of each iteration
• at the end of the loop .
4. What is the relationship between loop invariant, loop condition and the input- output recursively
a. Establish the loop invariant at the start of the loop.
b. The loop body should be update the variables and maintain the loop invariant, at the same time.
c. When the loop ends, the termination condition and the loop invariant should establish the input-output
relation.
5. What is recursive problem solving?
1. There are 7 tumblers on a table, all standing upside down. You are allowed to turn any 2 tumblers
simultaneously in one move. Is it possible to reach a situation when all the tumblers are right side up? (Hint: The
parity of the number of upside down tumblers is invariant.)
Step 2.
Step 3.
p + g : = 1234 g =1234 – 1
3. King Vikramaditya has two magic swords. With one, he can cut off 19 heads of a dragon, but after that the
dragon grows 13 heads. With the other sword, he can cut off 7 heads, but 22 new heads grow. If all heads are cut
off, the dragon dies. If the dragon has originally 1000 heads, can it ever die? (Hint:The number of heads mod 3 is
invariant.)
If the dragon has 1000 heads we start at 1000=1(mod 3) we cannot get to 0 .so the dragon lives.
SECTION – D
Explain in detail
1. Assume an 8 × 8 chessboard with the usual coloring. "Recoloring" operation changes the color of all squares
of a row or a column. You can recolor re-peatedly. The goal is to attain just one black square. Show that you
cannot achieve the goal. (Hint: If a row or column has b black squares, it changes by (|8 - b) - b|).
W+ B = 64 , W – B = 0 = 0 mod 4
state has 63 W 1 B
So W – B = 63 – 1= 62 = 2 mod 4
Which is impossible.
2. Power can also be defined recursively as { a n = 1 if n = 0 a × an -1 if n is odd a n/2 × a n/2 if n is even Construct
a recursive algorithm using this definition. How many multiplications are needed to calculate a10?
Power (a,n)
--inputs : n integer
--output : a n
else if (n is odd)
a x power (a , a n-1) -- recursion step
else (n is even)
Part – II
Answer to all the questions
1. What is meant by a token? Name the token available in C++.
Keywords
Identifiers
Constants
Operators
Punctuator
Part – III
Answer to all the questions
1. Describe the differences between keywords and identifiers?
KEYWORDS IDENTIFIERS
Keywords are the reserved words which Identifiers are the user-defined names
convey specific meaning to the C++ given to different parts of the C++
compiler. program
Keywords are the essential elements to These are the fundamental building
construct C++ programs. blocks of a program.
EX: int , void , break , do , if etc.. EX: variable_name, function_name,
array_name, classe_name etc..
= ==
It is an assignment statement It is relational Operator
It is used to assign a value to a variable which is It is used to compare 2 values and the result will
on the left hand side of an assignment statement be either true or false
EX: EX:
a=b a == b
(b value is assigned to a) (a value will be compared with b value)
Usually all C++ programs begin with include statements starting with a #
(hash /pound).
The symbol # is a directive for the preprocessor. That means, these
statements are processed before the compilation process begins.
#include <iostream> statement tells the compiler‟s preprocessor to include
the header file “iostream” in the program. The header file iostream should
included in every C++ program to implement input /output functionalities.
iostream header file contains the definition of its member objects cin and
cout.
If you fail to include iostream in your program, an error message will
occur on cin and cout; and we will not be able to get any input or send any
output.
2. Relational Operators
Relational operators are used to determine the relationship between its operands. When the relational
operators are applied on two operands, the result will be a Boolean value i.e 1 or 0 to represents
True or False respectively.
3. Logical Operators
A logical operator is used to evaluate logical and relational expressions. The logical
operators act upon the operands that are themselves called as logical expressions.
C++ provides three logical operators
4. Assignment Operator:
This operator copies the value at the right side of the operator to
the left side variable. It is also a binary operator.
5. Conditional Operator:
5.How many bytes of memory allocates for the following variable declaration if
you are using
Dev C++? short int x;
(a) 2 (b) 4 (c) 6 (d) 8
8.Which of the following operator returns the size of the data type?
(a) sizeof() (b) int () (c) long () (d) double ()
PART – 2
II. Answer to all the questions
7.Determine which of the following are valid constant? And specify their
type.
10.Which of the following two statements are valid? Why? Also write their
result, int a; a = 3,014; a=(3,014);
It is invalid as comma is not allowed in an integer constant. It is valid.
Comma in bracket is allowed.
PART – 3
III. Answer to all the questions
1. n = x + y / x;
2. z = m * x + y;
3. z = (x++) * m + x;
Answer:
1. n = x + y / x;
= 5 + 4/5
= 5 + 0 (both x and y are int type. Therefore only integer part of quotient is
considered)
=5
2. z = m * x + y;
= 2.5 * 5 + 4 (m is float type, so x value is promoted to float [implicit
conversion])
= 12.5 + 4 ‘
= 16 (2 is int type. So ‘.2’, the fractional part is discarded)
3. z = (x++) * m + x;
= 5*2.5 + x
= 12.5 + 5
= 18 (z is int type, therefore the fractional part is removed, x is
incremented after the addition)
*******************************
Computer Science
PART – I
3. The set of statements that are executed again and again in iteration is
called as:
6. How many times the following loop will execute? for (int i=0; i<10; i++)
Part – II
• The selection statement means the statement (s) are executed depends
upon a condition.
• If a condition is true, a true block (a set of statements) is executed
otherwise a false block is
executed. This statement is also called decision statement or selection
statement
Types:
If, if else, Nest if, if -else-if ladder, The ?: Alternative to if- else, Switch
statement
if (x=1)
p = 100;
else
p = 10;
Answer:
if (x= =1)
p = 100;
else
p = 10;
int year;
if (year % 100 == 0)
if ( year % 400 == 0)
else
output:
10
6. Write a for loop that displays the number from 21 to 30.
#include <iostream>
int main()
int i;
return 0;
#include <iostream>
int main()
int i;
return 0;
Syntax: Syntax:
if (expression) expression 1? expression 2 :
true-block; expression 3
statement-x;
Part – III
if (x >= 10)
a = m + 5;
else
a = m;
Answer:
a= (x >= 10) ? m + 5 : m ;
v = 5;
do;
total += v;
}while v <= 10
Answer:
int v = 5;
do
{
cout << v;
total += v;
}while (v <= 10);
#include<iostream>
int main()
int num;
cin>>num;
for(int a=1;a<=10;a++)
return 0;
Output:
4. Write the syntax and purpose of switch statement.
Syntax of switch
switch(expression)
case constant 1:
statement(s);
break;
case constant 2:
statement(s);
break;
default:
statement(s);
#include<iostream>
int main()
int i;
for(i=1;i<=40;i+=3)
cout<<”\t<<i;
return 0;
Part – IV
Loop body will be executed first, and then condition is checked. ......... If Test
condition is false, loop
• for loop
• while loop
for loop:
Statement 1;
Statement 2;
………….
Statement-x;
Example Program:
#include <iostream>
int main ()
int i;
for(i = 0; i< 5; i ++ )
cout<< "value of i : " <<i<<endl;
return 0;
}
Output
value of i : 0
value of i : 1
value of i : 2
value of i : 3
value of i : 4
#include <iostream>
int main() {
int a, b, x, y, t, gcd, lcm;
a = x;
b = y;
while (b != 0) {
t = b;
b = a % b;
a = t;
}
gcd = a;
lcm = (x*y)/gcd;
cout<<"Greatest common divisor of "<<x<<" and "<<y<<"="<<gcd;
cout<<"Least common multiple of "<<x<<" and "<<y<<"="<<lcm;
return 0;
}
Output:
Output:
#include <iostream>
using namespace std;
int main()
{
clrscr();
int i,n;
float x,sum=0;
cout<<“x+x^2/2+x^3/3+…..+x^n/n”;
cout<<“\n Enter value of x and n:”;
cin>>x>>n;
for(i=1;i<=n;++i)
sum+=pow(x,i)/i;
cout<<“\n sum=”<<sum;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
clrscr();
long i,n,x,sum=1;
cout<<“1+x+x^2+……+x^n”;
cout<<“\n Enter the value of x and n:”;
cin>>x>>n;
for(i=1;i<=n;++i)
sum+=pow(x,i);
cout<<“\n Sum=”<<sum;
getch();
}
Output:
Chapter 11 Functions
PART–1
I. Choose The Correct Answer
Question1.
Which of the following header file defines the standard I/O predefined functions?
(a) stdio.h (b) math.h (c) string.h (d) ctype.h
Answer:
(a) stdio.h
Question2.
Which function is used to check whether a character is alphanumeric or not?
(a) isalpha() (b) isdigit() (c) isalnum() (d) islower()
Answer:
(c) isalnum()
Question3.
Which function begins the program execution?
(a) isalpha() (b) isdigit() (c) main() (d) islower()
Answer:
(c) main()
Question4.
Which of the following function is with a return value and without any argument?
(a) x = display(int, int) (b) x = display() (c) y = display(float) (d) display(int)
Answer:
(b) x = display()
Question5.
Which is return data type of the function prototype of add(int, int);?
(a) int (b) float (c) char (d) double
Answer:
(a) int
Question6.
Which of the following is the scope operator?
(a) > (b) & (c) % (d) ::
Answer:
(d) ::
PART–2
II. Answer to all the questions
Question1.
DefineFunctions.
Answer:
A large program can typically be split into small sub – programs (blocks) called as
functions where each sub-program can perform some specific functionality. Functions
reduce the size and complexity of a program, makes it easier to understand, test and check
for errors.
Question2.
Write about strlen() function.
Answer:
The strlen() takes a null terminated byte string source as its argument and returns its
length. The length does not include the null(\0) character.
Question 3.
What are importance of void data type? void type has two important purposes:
Answer:
1. To indicate the function does not return a value.
2. To declare a generic pointer.
Question 4.
What is Parameter and list its types?
Answer:
Arguments or parameters are the means to pass values from the calling function to the
called function. The variables used in the function definition as parameters are known as
formal parameters. The constants, variables or expressions used in the function call are
known as actual parameters. Types : Default arguments and Constant Arguments.
Question 5.
Write a note on Local Scope.
Answer:
1. A local variable is defined within a block. A block of code begins and ends with
curly braces { }.
2. The scope of a local variable is the block in which it is defined.
3. A local variable cannot be accessed from outside the block of its declaration.
4. A local variable is created upon entry into its block and destroyed upon exit.
PART – 3
III. Answer to all the questions
Question 1.
What is Built – in functions?
Answer:
C++ provides a rich collection of functions ready to be used for various tasks. The tasks
to be performed by each of these are already written, debugged and compiled, their
definitions alone are grouped and stored in files called header files. Such ready – to – use
sub programs are called pre – defined functions or built – in functions.
Question 2.
What is the difference between isupper() and toupper() functions?
Answer:
isupper():
This function is used to convert the given character into its uppercase.
This function will return the upper case equivalent of the given character. If the
given character itself is in upper case, the output will be the same.
Question 3.
Write about strcmp() function.
Answer:
The strcmp() function takes two arguments: string1 and string2. It compares the
contents of string1 and string2 lexicographically.
The strcmp() function returns a:
1. Positive value if the first differing character in string1 is greater than the
corresponding character in string2. (ASCII values are compared)
2. Negative value if the first differing character in string1 is less than the
corresponding character in string2.
3. 0 if string1 and string2 are equal.
Question 4.
Write short note on pow() function in C++.
Answer:
The pow() function returns base raised to the power of exponent. If any argument passed
to pow() is long double, the return type is promoted to long double. If not, the return type
is double. The pow() function takes two arguments:
Output:
25
Question 5.
What are the information the prototype provides to the compiler?
Answer:
The prototype above provides the following information to the compiler:
1. The return value of the function is of type long.
2. Fact is the name of the function.
3. The function is called with two arguments:
The first argument is of int data type.
The second argument is of double data type, int display(int, int) // function
prototype//.
The above function prototype provides details about the return data type, name of
the function and a list of formal parameters or arguments.
Question 6.
What is default arguments? Give example.
Answer:
In C++, one can assign default values to the formal parameters of a function prototype.
The Default arguments allows to omit some arguments when calling the function.
1. For any missing arguments, complier uses the values in default arguments for the
called function.
PART – 4
IV. Answers to all the questions
Question 1.
Explain Call by value method with suitable example.
Answer:
This method copies the value of an actual parameter into the formal parameter of the
function. In this case, changes made to formal parameter within the function will have
no effect on the actual parameter.
Question 2.
What is Recursion? Write a program to find GCD using recursion.
Answer:
A function that calls itself is known as recursive function. And, this technique is known
as recursion.
Question 3.
What are the different forms of function return? Explain with example.
Answer:
The return statement:
Returning from the function is done by using the return statement. The return statement
stops execution and returns to the calling function. When a return statement is
executed, the function is terminated immediately at that point. The return statement is
used to return from a function. It is categorized as a jump statement because it
terminates the execution of the function and transfer the control to the called statement.
Syntax:
return expression/variable;
Example : retun(a + b); retun(a);
return; // to terminate the function
int n 1 = 150;
int &n 1 ref = n1;
cout << “\nThe Value of N1 = “<< n1 << “and n 1 Reference =”<< n 1 ref;
n 1 ref++;
cout << “\n After nl increased the Value of N1 =”<< n1;
cout << “and n 1 Reference = ”<< n 1 ref;
retum(0);
}
Output:
The Value of N1 = 150 and nl Reference =150
After n1 increased the Value of N1 = 151 and n1 Reference =151
Question 4.
Explain scope of variable with example.
Answer:
Scope refers to the accessibility of a variable.
There are four types of scopes in C++
1. Local Scope
2. Function Scope
3. File Scope
4. Class Scope
1. Local Scope:
A local variable is defined within a block. A block of code begins and ends with
curly braces {}.
The scope of a local variable is the block in which it is defined.
A local variable cannot be accessed from outside the block of its declaration.
A local variable is created upon entry into its block and destroyed upon exit;
Example:
int main( )
{
int a,b; //Local variable
}
2. Function Scope:
The scope of variable within a function is extended to the function block and all
sub-blocks therein.
The lifetime of a function scope variable is the lifetime of the function block.
Example:
int. sum(intx, int y); //x and y has function scope.
3. File Scope:
A variable declared above all blocks and functions (including main()) has the scope
of a file.
The lifetime of a file scope variable is the lifetime of a program.
The file scope variable is also called as global variable.
Example:
#include
using namespace std;
int x,y; //x and y are global variable
void main()
{
……..
}
4. Class Scope:
Data members declared in a class has the class scope.
Data members declared in a class can be accessed by all member functions of the
class.
Example:
Class example
{
int x,y; //x and y can be accessed by print() and void():
void print();
Void total();
};
Question 5.
Write a program to accept any integer number and reverse it.
Answer:
Chapter 12 Arrays and Structures
PART – 1
I. Choose The Correct Answer
1. Which of the following is the collection of variables of the same type that an referenced
by a common name?
(a) int (b) float (c) Array (d) class Answer:(c)Array
2.int age[ ]={6, 90, 20, 18, 2}; How many elements are there in this array?
(a) 2 (b) 5 (c) 6 (d) 4 Answer:(b) 5
3. cin >> n[3]; To which element does this statement accepts the value?
(a) 2 (b) 3 (c) 4 (d) 5 Answer:(c) 4
10.When accessing a structure member, the identifier to the left of thedot operator is
the name of …………………
a.structure variable (b) structure tag
(c) structure member (d) structure function
PART – 2
II. Answers to all the questions
Question 1.
What is Traversal in an Array? Answer:
Accessing each element of an array at least once to perform any operation is known as
“Traversal”. Displaying all the elements in an array is an example of “traversal”.
Question 2.
Whatis Strings?
Answer:
A string is defined as a sequence of characters where each character may be a letter,
number or a symbol. Each element occupies one byte of memory. Every string is
terminated by a null (‘\0’, ASCII code 0) character which must be appended at the end of
the string.
Question 3.
What is the syntax to declare two – dimensional array.
Answer:
The declaration of a 2 – D array is
data – type array_name[row – size] [col – size];
In the above declaration, data-type refers to any valid C++ data – type, array _ name
refers to the name of the 2 – D array, row – size refers to the number of rows and col-
size refers to the number of columns in the 2 – D array.
Question 1.
Define an Array. What are the types?
Answer:
“An array is a collection of variables of the same type that are referenced by a common
name”. An array is also a derived datatype in C++.
There are different types of arrays used in C++. They are:
Question 2.
Write a note on Array of strings.
Answer:
An array of strings is a two – dimensional character array. The size of the first Index
(rows) denotes the number of strings and the size of the second index (columns)
denotes the maximum length of each string. Usually, array of strings are declared in
such a way to accommodate the null character at the end of each string. For example,
the 2 – D array has the declaration:
char name [7][10];
In the above declaration,
No. of rows = 7;
No. of columns =10;
We can store 7 strings each of maximum length 10 characters.
3. The following code sums up the total of all students name starting
with ‘S’ and display it. Fill in the blanks with required statements.
4. How to access members of a structure? Give example.
Once objects of a structure type are declared, their members can beaccessed
directly. The syntax for that is using a dot(.) between the object name and the
member name.
Example:
struct
{
long rollno;
int age;
float weight;
}student;
The student can be referred as reference name to the above structure and theelements
can be accessed like student.roll no, student.age, and student.weight.
PART – 4
I. Answers to all the questions
Question 1.
Write a C++ program to find the difference between two matrix.
Answer:
2. Write a C++ program to add two distances using the following
structure definition
Answer:
int main()
{
cout << “Enter 1st distance:” << end1;
cout << “Enter feet:”; cin >> d1.feet;
cout << “Enter inch:”; cin >> d1.inch;
cout << “\n information for 2nd distance:” << end1;
cout << “Enter feet:”; cin >> d2.feet;
cout << “Enter inch:”; cin >> d2.inch;
sum.feet = d1 . feet + d2.feet;
sum.inch = d1.inch + d2.inch;
if (sum.inch > 12)
{
++ sum.feet;
sum.inch = 12;
}
cout << end1; “Sum of distance =” << sum.feet << “feet” << sum.inch <<“inches”;
return 0;
}
Output:
Enter 1 st distance
Enter feet: 6
Enter inch: 3.4
Enter 2nd distance
Enter feet: 5
Enter inch: 10.2
Sum of distances = 12 feet 1.6 inches
3. Write the output of the following C++ programOutput
Details of Book No. 1
………………………………….
Book name : Programming
Book author : Dromy
…………………………………..
Details of Book No. 2
Book Name : C++ Programming
Book Author : Bjame Stroustrup
………………………………..
………………………………..
I |programming | Dromy
…………………………………
…………………………………
2| C++ Programming | Bjame Stroustrup
……………………………….
………………………………
4. Write the output of the following C++ program
Output
First student
roll no : 1
name : Brown
Phone no. : 123443
Second Student roll
no : 2
name : Sam
Phone no. : 1234567822
5. Debug the error in the following program
Corrected Program:
Chapter 13
PART – 1
I. Choose The Correct Answer
Question 1.
The term is used to describe a programming approach based on classes and objects
(a) OOP (b) POP (c) ADT (d) SOP Answer: (a) OOP
Question 2.
The paradigm which aims more at procedures ……………….
(a) Object Oriented Programming (b) Procedural programming
(c) Modular programming (d) Structural programming
Answer: (b) Procedural
programming
Question 3.
Which of the following is a user defined data type?
(a) class (b) float (c) int (d) object Answer: (a) class
Question 4.
The identifiable entity with some characteristics and behaviour is ……………….
(a) class (b) object (c) structure (d) member Answer: (b) object
Question 5.
The mechanism by which the data and functions are bound together into a single unit is
known as ……………….
(a) Inheritance (b) Encapsulation (c) Polymorphism (d) Abstraction
Answer:(b) Encapsulation
Question 6.
Insulation of the data from direct access by the program is called as ……………….
(a) Data hiding (b) Encapsulation (c) Polymorphism (d) Abstraction
Answer:(a) Data hiding
Question 7.
Which of the following concept encapsulate all the essential properties of the object that
are to be created?
(a) Class (b) Encapsulation (c) Polymorphism (d) Abstraction
Answer:(d) Abstraction
Question 8.
Which of the following is the most important advantage of inheritance?
(a) data hiding (b) code reusability (c) code modification (d) accessibility
Answer:(b) code reusability
Question 9.
“Write once and use it multiple time” can be achieved by ……………….
(a) redundancy (b) reusability (c) modification (d) composition
Answer:(b) reusability
Question 10.
Which of the following supports the transitive nature of data?
(a) Inheritance (b) Encapsulation (c) Polymorphism (d) Abstraction
Answer:(a) Inheritance
PART – 2
II. Answers to all the questions
Question 1.
How is modular programming different from procedural programming paradigm?
Answer:
Modular programming:
Question 4.
How is encapsulation and abstraction are interrelated?
Answer:
Abstraction means giving only essential things and hiding unnecessary details.
Encapsulation is the binding of data members and methods together in a capsule to avoid
accidental changes to data from external users, i.e., encapsulation is the bundling of
related algorithms and data.
Question 5.
Write the disadvantages of OOP.
Answer:
1. Size: Object Oriented Programs are much larger than other programs.
2. Effort: Object Oriented Programs require a lot of work to create.
3. Speed: Object Oriented Programs are slower than other programs, because of their
size.
PART – 3
III. Answers to all the questions
Question 1.
What is paradigm? Mention the different types of paradigm.
Answer:
Paradigm means organizing principle of a program. It is an approach to programming.
There are different approaches available for problem solving using computer. They are
Procedural programming, Modular Programming and Object Oriented Programming.
Question 2.
Write a note on the features of procedural programming.
Answer:
Important features of procedural programming
Question 3.
List some of the features of modular programming.
Answer:
Important features of Modular programming:
Question 4.
What do you mean by modularization and software reuse?
Answer:
Question 5.
Define information hiding.
Answer:
Encapsulation is the most striking feature of a class. The data is not accessible to the
outside world, and only those functions which are wrapped in the class can access it. This
encapsulation of data from direct access by the program is called data hiding or
information hiding.
PART – 4
IV. Answers to all the questions
Question 1.
Write the differences between Object Oriented Programming and Procedural Programming
Answer:
Object Oriented Programming:
Question 2.
What are the advantages of OOPs?
Answer:
Re – usability : “Write once and use it multiple times” you can achieve this by using class.
Redundancy: Inheritance is the good feature for data redundancy. If you need a same
functionality in multiple class you can write a common class for the same functionality
and inherit that class to sub class.
Easy Maintenance : It is easy to maintain and modify existing code as new objects can be
created with small differences to existing ones.
Security : Using data hiding and abstraction only necessary data will be provided thus
maintains the security of data.
Question 3.
Write a note on the basic concepts that supports OOPs?
Answer:
The Object Oriented Programming has been developed to overcome the drawbacks of
procedural and modular programming. It is widely accepted that object – oriented
programming is the most important and powerful way of creating software.
1. Data Abstraction.
2. Encapsulation.
3. Modularity.
4. Inheritance.
5. Polymorphism.
Encapsulation:
The mechanism by which the data and functions are bound together into a single unit is
known as Encapsulation. It implements abstraction. Encapsulation is about binding the
data variables and functions together in class. It can also be called data binding.
Encapsulation is the most striking feature of a class.
The data is not accessible to the outside world, and only those functions which are
wrapped in the class can access it. These functions provide the interface between the
object’s data and the program. This encapsulation of data from direct access by the
program is called data hiding or information hiding.
Data Abstraction:
Abstraction refers to showing only the essential features without revealing background
details. Classes use the concept of abstraction to define a list of abstract attributes and
function which operate on these attributes. They encapsulate all the essential properties
of the object that are to be created. The attributes are called data members because they
hold information. The functions that operate on these data are called methods or member
function.
Modularity:
Modularity is designing a system that is divided into a set of functional units (named
modules) that can be composed into a larger application.
Inheritance:
Inheritance is the technique of building new classes (derived class) from an existing Class
(base class). The most important advantage of inheritance is code reusability.
Polymorphism:
Polymorphism is the ability of a message or function to be displayed in more than one
form.
Lesson 14 Classes and Objects
PART – 1
I. Choose The Correct Answer
1. The variables declared inside the class are known as ____________
(a) data (b) inline
(c) member functions (d) attributes
4. The member function defined within the class behave like ………………..
(a) inline function (b) Non – inline function
(c) Outline function (d) Data function
6. class x
{
int y; public:
x(int z){y=z;}
}x1[4];
int main()
{x x2(10);
return 0;}
How many objects are created for the above program?
(a) 10 (b) 14 (c) 5 (d) 2
7. State whether the following statements about the constructor are True or
False.
(i) constructors should be declared in the private section.
(ii) constructors are invoked automatically when the objects are created.
(a) True, True (b) True, False (c) False, True (d) False, False
8.Which of the following constructor is executed for the following prototype?
add display( add &); // add is a class name
(a) Default constructor (b) Parameterized constructor
(c) Copy constructor (d) Non-Parameterized constructor
PART – 2
II. Answers to all the questions
1. What are called members?
The class body contains the declaration of its members – Data member and
Member functions.
2. Differentiate structure and class though both are user-defined data types.
The only difference between structure and class is the members of the structure
are by default public whereas it is private in class.
3. What is the difference between the class and object in terms of OOP?
A class specification just defines the properties of a class. To make use of a class
specified, the variables of that class type have to be declared.
The class variables are called objects. Objects are also called an instance of the class.
Constructor:
• The destructor has the same name as that of the class prefixed by the
tilde character
• It has no return type.
• The destructor cannot have arguments
• Destructors cannot be overloaded i.e., there can be only one destructor
in a class.
• They cannot be inherited.
• In the absence of user defined destructor, it is generated by the
compiler.
Class RESORT
{
Private:
int Rno;
char name [20];
float charges;
int days;
float compute( );
Public:
void getinf( );
void dispinfo( );
}
void RESORT: : getinfo()
{
cout << “Enter Registration number:”; cin >> Rno.;
cout << “\n Enter name:”;
gets(name);
cout << “\n Enter per day charges:”; cin >> charges;
cout << “\n Enter number of days:”; cin >> days;
}
void RESORT: : dispinfo()
{
cout << “\n 1. Registration number:” << Rno;
cout << “\n 2. Name:”;
puts(name);
cout << “\n 3. charges per day:” << charges ;
cout<< “\n 4. Number of days:” <<days;
cout<< “\n 5. Amount:” <<compute( );
int compute()
{
long float;
amount = charges*days;
if (amount> 11000)
amount = 1,02*days*charges;
return amount;
}
RESORT obj;
void main()
{
clrscr();
obj.getinfo();
obj.dispinfoQ;
getch();
}
Constructor
Name : Bharathi
Roll no : 14
Marks: 100
Back to main
***************************
Chapter 15 Polymorphism
I. Choose The Correct Answer
Question 1.
Which of the following refers to a function having more than one distinct meaning?
(a) Function Overloading (b) Member overloading
(c) Operator overloading (d) Operations overloading
Answer: (a) Function Overloading
Question 2.
Which of the following reduces the number of comparisons in a program?
(a) Operator Overloadig (b) Operations overloading
(c) Function overloading (d) Member overloading
Answer: (c) Function overloading
Question 3.
void dispchar(char ch = ‘$\ int size=10)
{
}
How will you invoke the function dispchar() for the following input?
To print $ for 10 times
(a) dispchar(); (b) dispchar(ch,size);
(c) dispchar($,10); (d) dispchar(T, 10 times);
Answer: (a) dispchar();
Question 4.
Which of the following is not true with respect to function overloading?
(a) The overloaded functions must differ in their signature.
(b) The return type is also considered for overloading a function.
(c) The default arguments of overloaded functions are not considered for overloading.
(d) Destructor function cannot be overloaded.
Answer:(b) The return type is also considered for overloading a function.
Question 5.
Which of the following is invalid prototype for function overloading
(a) void fun (intx); void fun (char ch);
(b) void fun (intx); void fun (inty);
(c) void fun (double d); void fun (char ch);
(d) void fun (double d); void fun (inty);
Answer:(b ) void fun (intx);void fun (inty);
PART – 2
II. Answers to all the questions
Question 1.
What is function overloading?
Answer:
• The ability of the function to process the message or data in more than one form is called
function overloading.
• In other words, function overloading means two or more functions in the same scope share
the same name but their parameters are different.
•
Question 2.
List the operators that cannot be overloaded.
Answer:
Operator that are not overloaded is as follows:
Question 3.
class add{int x; public: add(int)}; Write an outline definition for the constructor.
Answer:
add (int temp)
{
x = temp;
}
Question 4.
Does the return type of function help in overloading a function?
Answer:
No. The return type of a function does not help in overloading a function. Only arguments are
considered.
Question 5.
What is the use of overloading a function?
Answer:
Function overloading is not only implementing polymorphism but also reduces the number of
comparisons in a program and makes the program execute faster. It also helps the programmer by
reducing the number of function names to be remembered.
PART – 3
III. Answers to all the questions
Question 1.
What are the rules for function overloading?
Answer:
Rules for function overloading:
• The overloaded function must differ in the number of its arguments or data types.
• The return type of overloaded functions is not considered for overloading the same data
type.
• The default arguments of overloaded functions are not considered as part of the parameter
list in function overloading.
•
Question 2.
How does a compiler decide as to which function should be invoked when there are many
functions? Give an example.
Answer:
When you call an overloaded function (when there are many functions with same name), the
compiler determines the most appropriate definition to use by comparing the argument types used
to call the function with the parameter types specified in the definitions. The process of selecting
the most appropriate overloaded function or operator is called overload resolution.
Example:
#include using namespace std; void print (int i)
{
cout<< “It is integer” <<i<< endl;
}
void print (string c)
{
cout<< “It is string”<< c << endl;
}
int main ()
{
print (10);
print (“Good”);
return 0;
}
Output:
It is integer 10
It is string Good
Question 3.
What is operator overloading? Give some example of operators which can be overloaded.
Answer:
The term operator overloading refers to giving additional functionality to the normal C++ operators
like It is also a type of polymorphism in which an operator is overloaded to give user-defined
meaning to it.
Integer, String (concatenation), etc.
Question 4.
Discuss the benefit of constructor overloading?
Answer:
• Function overloading can be applied for constructors, as constructors are special functions of
classes.
• A class can have more than one constructor with a different signature.
• Constructor overloading provides the flexibility of creating multiple type of objects for a class.
Question 5.
class sale ( int cost, discount; public: sale(sale &); Write a non-inline definition for constructor
specified;
Answer:
class sale
{
int cost, discount;
public:
sale (sale&);
};
// non inline constructor
sale: : sale(sale&s)
{
cost = s.cost;
discount = s.discount;
}
PART – 4
IV. Answers to all the questions
Question 1.
What are the rules for operator overloading?
Answer:
Rules for operator overloading:
Output:
Seminar starts now Welcome to seminar
Recap of previous seminar contentLectures in the
seminar on
Vote of thanks Vote of thanks
Vote of thanks
Question 2.
Which of the following derives a class student from the base class Shool?
(a) school: student (b) class student: public school
(c) student: public school (d) class school : public student
Answer: (b) class student: public school
Question 3.
The type of inheritance that reflects the transitive nature is ………………
(a) Single Inheritance (b) Multiple Inheritance
(c) Multilevel Inheritance (d) Hybrid Inheritance
Answer: (c) Multilevel Inheritance
Question 4.
Which visibility mode should be used when you want the features of the base class to be
available to the derived class but not to the classes that are derived from the derived class?
(a) Private (b) Public
(c) Protected (d) All of these
Answer: (a) Private
Question 5.
Inheritance is process of creating new class from ………………
(a) Base class (b) abstract
(c) derived class (d) Function
Answer: (a) Base class
Question 6.
A class is derived from a class which is a derived class itself, then this is referred to as ……………….
(a) multiple inheritance (b) multilevel inheritance
(c) single inheritance (d) double inheritance
Answer: (b) multilevel inheritance
Question 7.
Which amongst the following is executed in the order of inheritance?
(a) Destructor (b) Member function
(c) Constructor (d) Object
Answer: (c) Constructor
Question 8.
Which of the following is true with respect to inheritance?
(a) Private members of base class are inherited to the derived class with private
(b) Private members of base class are not inherited to the derived class with private accessibility
(c) Public members of base class are inherited but not visible to the derived class
(d) Protected members of base class are inherited but not visible to the outside class
Answer:
(b) Private members of base class are not inherited to the derived class with private
accessibility
Question 9.
Based on the following class declaration answer the questions (from 9.1 to 9.4)
class vehicle
{ int wheels;
public:
void input_data(float,float);
void output_data();
protected:
int passenger;
};
class heavyvehicle : protected vehicle {
int diesel_petrol;
protected:
int load;
protected:
int load;
public:
voidread_data(float,float)
voidwrite_data(); };
class bus: private heavy vehicle {
charTicket[20];
public:
voidfetch_data(char); voiddisplay_data(); };
};
Question 9.1.
Which is the base class of the class heavy_vehicle?
(a) Bus (b) heavy_vehicle
(c) vehicle (d) both (a) and (c)
Answer: (c) vehicle
Question 9.2.
The data member that can be accessed from the function displaydata()
(a) passenger (b) load
(c) Ticket (d) All of these
Answer: (d) All of these
Question 9.3.
The member function that can be accessed by an objects of bus Class is
(a) input_data() (b) read_data(), output_data()write_data()
(c) fetch_data() (d) All of these display_data()
Answer: (d) All of these
Question 9.4.
The member function that is inherited as public by Class Bus
(a) input_data() (b) read_data(), output_data()write_data()
(c) fetch_data() (d)none of these
Answer: (d) none of these
PART – 2
II. Answers to all the questions
Question 1.
What is inheritance?
Answer:
It is a process of creating new classes called derived classes, from the existing or base classes.
Question 2.
What is a base class?
Answer:
A class that is used as the basis for inheritance is called a superclass or base class.
Question 3.
Why derived class is called a power-packed class?
Answer:
The derived class is a power-packed class, as it can add additional attributes and methods and
thus enhance its functionality.
Question 4.
In what multilevel and multiple inheritances differ though both contain many base class?
Answer:
The derived class is a power-packed class, as it can add additional attributes and methods and
thus enhance its functionality.
5.What is the difference between public and private visibility mode?
Private visibility mode:
When a base class is inherited with private visibility mode the public and
protected members of the base class become ‘private’ members of the derived
class.
Public visibility mode:
When a base class is inherited with public visibility mode, the protected members
of the base class will be inherited as protected members of the derived class
and the public members of the base class will be inherited aspublic members
of the derived class.
PART – 3
III. Answers to all the questions
Question 1.
What are the points to be noted while deriving a new class?
Answer:
The following points should be observed for defining the derived class.
• The keyword class has to be used.
• The name of the derived class is to be given after the keyword class.
• A single colon.
• The type of derivation (the visibility mode), namely private, public, or protected. If
no visibility mode is specified, then by default the visibility mode is considered
private.
• The names of all base classes(parent classes) separated by a comma.
Question 3.
What is the difference between polymorphism and inheritance though both are used for the
reusability of code?
Answer:
Inheritance:
• Promotes code sharing and reduces development cost.
• Inheritance is implemented in classes.
• Inheritance type may be a single inheritance, multiple inheritances, multilevel
inheritance, hierarchical inheritance, and hybrid inheritance.
Polymorphism:
• Reduces the complexity of the program.
• Polymorphism is a common interface for multiple forms.
• Polymorphism is basically implemented on function.
• Polymorphism may be a compile Time polymorphism (overloading) or run-
time polymorphism (overriding).
4. What do you mean by overriding?
When a derived class member function has the same name as that of its base
class member function, the derived class member function shadows/hides the
base class’s inherited function. This situation is calledfunction overriding.
• Own (Derived) class constructors are executed first, before the base
classdestructors execution.
• A derived class can not inherit the destructor.
• In multilevel inheritance, the destructors will be executed in the
reverseorder of inheritance.
PART – 4
IV. Answers to all the questions
Question 1.
Explain the different types of inheritance.
Answer:
Types of Inheritance: There are different types of inheritance viz., Single inheritance, Multiple
inheritance, Multilevel inheritance, hybrid inheritance, and hierarchical inheritance.
1. Single Inheritance: When a derived class inherits only from one base class, it is known
as single inheritance.
2. Multiple Inheritance: When a derived class inherits from multiple base classes it is known
as multiple inheritances.
3. Hierarchical inheritance: When more than one derived class is created from a single
base class, it is known as Hierarchical inheritance.
4. Multilevel Inheritance: The transitive nature of inheritance is itself reflected by this form
of inheritance. When a class is derived from a class which is a derived class then it is
referred to as multilevel inheritance.
5. Hybrid inheritance: When there is a combination of more than one type of inheritance,
it is known as hybrid inheritance.
6. Hence, it may be a combination of Multilevel and Multiple inheritances or Hierarchical
and Multilevel inheritance or Hierarchical, Multilevel and Multiple inheritances.
The default visibility mode is private. Though visibility modes and access
specifiers look similar, the main difference between them is Access specifierscontrol
the accessibility of the members within the class whereas visibility modes control
the access of inherited members within the class.
3.8.
4. Write the output of the following program
Output:
I am class A
I am class B
X = 30 Y = 20
Bye Bye
Bye
Part II
Answer to the following questions (2 Marks):
1. What is harvesting?
A person or program collects login and password information from a
legitimate user to illegally gain access to others’ account(s).
2. What are Warez?
Commercial programs that are made available to the public illegally are
often called warez.
3. Write a short note on cracking.
Cracking is where someone edits a program source so that the code can be exploited or
modified. A cracker (also called a black hat or dark side hacker) is a malicious or
criminal hacker.
4. Write two types of cyber attacks.
Malware is a type of software designed through which the criminals gain illegal access
to software and cause damage.
Types: 1. Virus, 2.Worms, 3.Spyware, 4. Ransomware
5. What is a Cookie? Part IV Answer
A cookie is a small piece of data sent from a website and stored on the user's to the following questions (5 Marks):
computer memory (Hard drive) by the user's web browser while the user is browsing 1. What are the various crimes happening using computer?
internet. Crime Function
Type of cookies: HTTP cookie, web cookie, Internet cookie, browser cookie, or Crime Hacking, threats, and blackmailing towards a
simply cookie Function business or a person.
Cyber stalking Harassing through online.
Part III Answer Malicious programs that can perform a variety
to the following questions (3 Marks): of functions including stealing, encrypting or
Malware
1. What is the role of firewalls?( layered security) deleting sensitive data, monitoring user’s
Firewalls also vary in type depending on where communication originates, computer activity without their permission.
where it is intercepted, and the state of communication being traced. Overloading a system with fake requests
Denial of
2. Write about encryption and decryption. so that it cannot serve normal legitimate
service attack
Encryption and decryption are processes that ensure confidentiality that requests.
only authorized persons can access the information.
Encryption is the process of translating the plain text data (plaintext) Manipulating data, for example changing the
into random and mangled data (called cipher-text). Fraud banking records to transfer money to an
Decryption reverse process of converting the cipher-text back to plaintext. unauthorized account.
Encryption and decryption are done by cryptography A person or program collects login and
3. What are the guidelines to be followed by any computer user? Harvesting password information from a legitimate user to
illegally gain access to others’ account(s).
Honesty: Users should be truthful while using the internet.
It is a crime where the criminals impersonate
Confidentiality: Users should not share any important information with Identity theft
individuals, usually for financial gain.
unauthorized people.
Intellectual Stealing practical or conceptual information
Respect: Each user should respect the privacy of other users. property theft developed by another person or company.
Professionalism: Each user should maintain professional conduct. Stealing tiny amounts of money from each
Obey The Law: Users should strictly obey the cyber law in computer usage. Salami slicing
transaction.
Responsibility: Each user should take ownership and responsibility for their Tricking people into believing something that
actions Scam
is not true.
4. What are ethical issues? Name some. Distribute unwanted e-mail to a large number
An Ethical issue is a problem or issue that requires a person or organization Spam
of internet users.
to choose between alternatives that must be evaluated as right (ethical) or wrong It is a malicious practice in which
(unethical). Spoofing communication is send from unknown source
These issues must be addressed and resolved to have a positive influence in disguised as a source known to the receiver.
society.
Some of the common ethical issues are listed below:
Cyber crime Use of computers to commit fraud
Software Piracy Sabotage in the form of viruses
Unauthorized Access Making false claims using computers
Hacking
.
3. Write the different types of cyber attacks
2. What is piracy? Mention the types of piracy How can S. Cyber
Function
it be prevented No Attack
Software Piracy is about the copyright violation of software created originally by A virus is a small piece of computer code that can repeat
an individual or an institution. itself and spreads from one computer to another by attaching
Software Piracy is “unauthorized copying of software” itself to another computer file.
S Type of Trojan: A Trojan virus is a program that appears to perform
Function 1. Virus
No Piracy one function (for example, virus removal) but actually
Unauthorized access is when someone gains performs malicious activity
Unauthoriz when executed.
1 ed access to a website, program, server, service,
access or other system by breaking into a legitimate
Worms are self- repeating and do not require a computer
user account. program to attach themselves. Worms continually look for
Hacking is gaining unauthorized access to s computer 2. Worms vulnerabilities and report back to the author of the worm when
2 Hacking system without the owner’s permission. weaknesses are
discovered.
Cracking is gaining unauthorized access to computer
systems to commit a crime, such as stealing the code to Spyware can be installed on the computer automatically
3 Cracking make a copy- when the attachments are open, by clicking on links or by
3. Spyware
protected program run thus denying service to downloading infected
software.
legitimate users.
Prevented Action: Ransomware is a type of malicious program that demands
To pretend being your friend and talk to you on Internet Relay Chat(IRC) or by payment after launching a cyber-attack on a computer
Ransom
Instant messenger. e-mail can also be a source for them. 4. system. This type of malware has
ware
They may send official e-mail requesting some sensitive information. become increasingly popular among criminals and costs the
organizations millions each year.
Computer Application- CHAPTER 18
Tamil Computing
1. List the search engines supported by Tamil language
Google and Bing provide searching facilities in Tamil,
which means you can search everything through Tamil. The
Google search engine gives you an inbuilt Tamil virtual
keyboard.
2. What are the keyboard layouts used in Android?
Sellinam and Ponmadal – are familiar Tamil keyboard
layouts that works on Android operating system in Smart
phone using phonetics.
3. Write a short note about Tamil Programming Language.
Programming languages to develop software in
computers and smart phones are available only in English.
Based on Python programming language, the first Tamil
programming language “Ezhil” (எழில் ) is designed.
4. What is TSCII?
TSCII (Tamil Script Code for Information Interchange) is
the first coding system to handle our Tamil language. This
encoding scheme was registered in IANA (Internet Assigned
Numbers Authority) a unit of ICANN.
5. Write a short note on Tamil Virtual Academy.
With the objectives of spreading Tamil to the entire
world through internet, Tamil Virtual University was
established on 17th February 2001 by the Govt. of
Tamilnadu. Now, this organisation functions with the name
of “Tamil Virtual Academy”. It offers different courses in Tamil
language, Culture, heritage etc., from kindergarten to under
graduation level.
Website: http://www.tamilvu.org/index.php
******************************