You are on page 1of 56

Computer Science - XI

Chapter 1: The Discipline of Computing

Abacus: Considered as the first computer for basic arithmetical calculations. Discovered by
the Mesopotamians around 3000 BC.

Napier’s bones: A set of numbering rods by which a multiplication problem could be easily
performed. Invented by John Napier, a mathematician in 1617 AD.

Pascaline: A computing machine that was capable of adding and subtracting two numbers
directly and that could multiply and divide by repetition. Developed by Blaise Pascal (a
French mathematician) in 1642, at the age of 19.

Leibniz’s Calculator: In 1673 the German mathematician-philosopher Gottfried Wilhelm von


Leibniz designed a calculating machine called the Step Reckoner. The Step Reckoner
expanded on Pascal’s ideas and extended the capabilities to perform multiplication and
division as well.

Difference Engine: In 1822, Babbage invented this machine that could perform arithmetic
calculations and print results automatically.

Analytical Engine: In 1833, Charles Babbage started designing the real predecessor of the
modern computer. The Engine had a ‘Store’ (memory) where numbers and intermediate
results could be stored, and a separate ‘Mill’ (processor) where arithmetic processing could
be performed. Its input/output devices were in the form of punched cards containing
instructions. These instructions were written by Babbage’s assistant, Agusta Ada King, the
first programmer in the world. Charles Babbage’s great inventions – the Difference Engine
and the Analytical Engine earned Charles Babbage the title ‘Father of Computer’.

Generations of Computers:

Von Neumann architecture:


The mathematician John Von Neumann designed computer architecture. It is known as Von
Neumann architecture. It consists of a central processing unit (CPU) containing arithmetic
logic unit (ALU) and control unit (CU), input-output unit and a memory for storing data and
Computer Science - XI
instructions. This model implements the ‘Stored Program Concept’ in which the data and
the instructions are stored in the memory.

Transistors: Developed at Bell Laboratories by John Bardeen, Walter Brattain and William
Shockley in 1947.

Integrated Circuits: Silicon chips that contained miniaturised transistors were developed by
Jack Kilby, an engineer with Texas Instruments.

Artificial Intelligence: AI is the ability to simulate human intelligence. AI is the branch of


computer science concerned with developing computer programs (intelligent systems) for
solving complex problems by the application of process that are analogues to human
reasoning process. The two most common AI programming languages are LISP and Prolog.
The fifth-generation computing also aims at developing computing machines that respond
to natural language input and are capable of learning and self-organisation. Such intelligent
systems are still in the development stage, though there are some applications, such as
speech recognition, face recognition and robotic vision and movement that are already
available.

Programming language: It is an artificial language designed to communicate instructions to


a computer. The first programming language developed for use in computers was called
machine language. Machine language consisted of strings of the binary digits 0 and 1. To
make programming easier, a new language with instructions consisting of English-like words
instead of 0’s and 1’s, was developed. This language was called assembly language. Later
new languages called high level languages were developed which are machine independent
and which used simple English-like words and statements.

Algorithm: a step by step procedure to get the solution for a given problem.

Turing Machine: A model of a computer proposed by Alan Turing in 1936. He made


significant contributions to the development of computer science, by presenting the
concepts of algorithm and computing. Turing proposed an imitation game which is later
modified to Turing test and it is considered to be the test for determining a machine's
intelligence. Considering these contributions he is regarded as the Father of Modern
Computer Science as well as Artificial Intelligence.

2
Computer Science - XI
Questions from Previous Years’ Question Papers
1. Who is known as the father of Modern Computer Science?
a) Alan Turing b) John Von Neumann
c) Charles Babbage d) Ada Lovelace (1) (July 2017)
2. Match the following:
a) First Generation Computer i) Microprocessor
b) Second Generation Computer (ii) Vacuum Tube
c) Third Generation Computer (iii) Transistor
d) Fourth Generation Computer (iv) Integrated Circuit
(2) (July 2017)
3. Compare any three features of five generations of computers. (3) (March 2017)
4. Order the following technologies according to different generations of computers (First
to Fifth Generation)
a) Transistor b) Vacuum tube c) Artificial intelligence d) Microprocessor
(1) (Sept. 2016)
5. Following are some facts related to the evolution of computers:
(Usage of transistors, Introduction to Very Large Scale Integration Circuit, Construction
of ENIAC)
Categorise these under respective generations and briefly explain each.
(3) (March 2016)
6. Which is the first automatic electromechanical computer?
a) Pascaline b) Abacus c) Mark I d) Analytical Engine
(1) (Sept 2015)
7. Find the correct match for each item in column A and column B. (2) (Sept 2015)
A B
a) Abacus i) Preprogrammed
b) Pascaline ii) Computing Machine
c) Jacquard’s Looms iii) Punched cards
d) Mark I iv) Counting frame
8. Write the number represented by the following Abacus. (1) (March 2015)
9. Briefly write the major changes in the technology during the different generations of
computers. (2) (March 2015)

3
Computer Science - XI

Chapter 2: Data Representation and Boolean Algebra

Base of a number system: The number of symbols used in a number system is called base or
radix of a number system

MSD and LSD: Left most digit of a number is MSD and right most digit of a number is LSD.

Different Number Systems:

Number Conversion procedure:

Number representation methods: (i) Sign and magnitude representation (ii) 1’s complement
representation (iii) 2’s complement representation.

ASCII: American Standard Code for Information Interchange. It uses 7 bits to represent a
character in computer memory. It can represent only128 characters. Another version is
ASCII-8 uses 8 bits for each character, can represent 256 different characters.

EBCDIC: Extended Binary Coded Decimal Interchange Code. This is similar to ASCII and is an
8 bit code. It can represent 256 characters.

4
Computer Science - XI
ISCII: Indian Standard Code for Information Interchange or Indian Script Code for
Information Interchange. It uses 8-bits and can represent various writing systems of India.

Unicode: Originally used 16 bits which can represent up to 65,536 characters. Nowadays
Unicode uses more than 16 bits and hence it can represent more characters. Unicode can
represent characters in almost all written languages of the world.

Boolean operations: The operations performed on the Boolean values 0s and 1s. The
operations are OR (Logical Addition), AND (Logical Multiplication), NOT (Logical Negation).

Logic gate: It is a physical device that can perform logical operations on one or more logical
inputs and produce a single logical output.
Truth Table: It is a table that shows Boolean operations and their results.

OR operation & Gate AND Operation & Gate NOT Operation & Gate

Boolean Laws:

De Morgan’s theorems:

Universal Gates: The NAND and NOR gates are called universal gates. A universal gate is a
gate which can implement any Boolean function without using any other gate type.

NAND: It is an inverted AND operation. NAND gate is an inverted AND gate.

2
Computer Science - XI
NOR: It is an inverted OR operation. NOR gate is an inverted OR gate.

NAND operation and NAND gate

NOR operation and NOR gate

AND using NAND:

OR using NOR:

AND using NOR:

NOT using NAND and NOR:

3
Computer Science - XI
Questions from Previous Years’ Question Papers
1. NAND gate is known as universal gate because it can be connected to other NAND gates
to generate any logic function. Show how will you connect NAND gates to produce OR
gate, AND gate and inverter. (3) (July 2017)
2. Represent the following integers in sign and magnitude form, 1’s complement from and
2’s complement form by using eight bits.
a) +25 b) –30 (3) (July 2017)
3. Briefly explain any three methods of representing characters in computer memory.
(3) (July 2017)
4. The number (158)10 can be represented in Hexadecimal number system as ………..

(1) (March 2017)


5. Represent –38 in 2’s complement form. (2) (March 2017)
6. Draw the logic circuit for the Boolean expression:
(A+ BC )+ AB (3) (March 2017)

7. Using algebraic method, prove that Y . Z + Y . Z+Y .Z + Y = 1 (3) (March 2017)


8. Which one of the following file extensions is different from others?
a) WAV b) MP3 c) PNG d) MIDI (1) (Sept. 2016)
9. Perform the following number conversions:
a) (110111011.11011)2 = ( ………… )8
b) (128.25)10 = ( ………… )8 (2) (Sept. 2016)
10. With the help of a neat circuit diagram, prove that NAND gate is a universal gate.
(2) (Sept. 2016)
11. 1’s compliment of the binary number 110111 is _ . (Hint: Use 8 bit form)
(1) (March 2016)
12. Express the integer number –39 in sign & magnitude representation. (2) (March 2016)
13. Following are the numbers in various number systems. Two of the numbers are same.
Identify them:
(a) (310)8 (b) (1010010)2 (c) (C8)16 (d) (201)10 (3) (March 2016)
14. Consider the following Boolean expression: (Bl+A)l = B. Al
Identify the law behind the above expression and prove it using algebraic method.
(3) (March 2016)
15. Computers use a fixed number of bits to represent data which could be a number, a
character, image, sound, video etc. Explain the various methods used to represent
characters in memory. (3) (Sept. 2015)
16. Draw the logic circuit for the function:
(3) (Sept. 2015)
17. Prove algebraically: x.(y.z) = x.y + x.z (3) (Sept. 2015)

4
Computer Science - XI
18. Fill in the blanks:
(a) (0.625)10 = ( )2
(b) (380)10 = ( )16
(c) (437)8 = ( )2 (3) (March 2015)
19. What do you mean by universal gates? Which gates are called universal gates? Draw
their symbols. (3) (March 2015)

20. Construct a logical circuit for the Boolean expression a . b + a . b . Also write the truth
table. (3) (March 2015)

Chapter 3: Computer System Organisation

Data processing: It refers to the operations or activities performed on data to generate


information. Data processing proceeds through six stages - Capturing data, Input of data,
Storage of data, Processing / manipulating data, Output of information, and Distribution of
information.
Capturing Data: Here a source document is designed to collect data.
Input: The data collected through the source documents is fed to the computer for
processing.
Storage: The input data are stored before processing.
Process: Various operations like calculation, classification, comparison, sorting, filtering,
summarising, etc. may be carried out as part of processing.
Output: The processed data is obtained in the form of information.
Distribution of information: The information obtained from the output stage is distributed to
the beneficiaries.

Functional Units of a computer: Input Unit, Central Processing Unit (CPU), Storage Unit and
Output Unit.

Input Unit: The data and instructions for their processing are entered into the computer
through the input unit. They are stored in the memory (storage unit). Eg: keyboard, mouse,
scanner, mic, digital camera, etc.

Central Processing Unit: CPU is the brain of the computer. It consists of three components -
Arithmetic Logic Unit (ALU), Control Unit (CU) and registers. ALU performs calculations and
logical operations such as comparisons and decision making. CU manages and co-ordinates
all other units of the computer. Registers are temporary storage elements that facilitate the
functions of CPU.

Storage Unit: It holds data and instructions required for processing, intermediate results for
ongoing processing and final results of processing.

5
Computer Science - XI

Output Unit: The information obtained after data processing is supplied to the outside
world through this unit. Monitor and printer are the commonly used output devices.

Computer: An electronic machine designed to accept the data and instructions, performs
arithmetic and logical operations on the data according to a set of instructions and output
the results or information.

Characteristics of computer: Speed, accuracy, diligence, versatility, huge memory, no IQ,


lack of decision making.

Important registers inside a CPU:


i. Accumulator: It is used to store intermediate result while performing arithmetic and
logical operations.
ii. Memory Address Register (MAR): It stores the address of a memory location to which
data is either to be read or written by the processor.
iii. Memory Buffer Register (MBR): It holds the data, either to be written to or read from
the memory by the processor.
iv. Instruction Register (IR): The instructions to be executed by the processor are stored
in the Instruction Register.
v. Program Counter (PC): It holds the address of the next instruction to be executed by
the processor.

Measuring units of memory:


Binary Digit = 1 Bit 1 MB (Mega Byte) = 1024 KB
1 Nibble = 4 Bits 1 GB (Giga Byte) = 1024 MB
1 Byte = 8 Bits 1 TB (Tera Byte) = 1024 GB
1 KB (Kilo Byte) = 1024 Bytes 1 PB (Peta Byte) = 1024 TB

RAM Vs ROM:

Cache memory: It is a small and fast memory between the processor and RAM (main
memory). Frequently accessed data, instructions, intermediate results, etc. are stored in
cache memory for quick access.
Storage unit of computer: Two types – primary and secondary.
i. Primary storage: It is also known as main memory. It is again divided into two –
6
Computer Science - XI
Random Access Memory (RAM) and Read Only Memory (ROM). RAM holds
instructions, data and intermediate results of processing. ROM contains instructions
for the start up procedure of the computer. The Central Processing Unit can directly
access the main memory at a very high speed. But it has limited storage capacity.
ii. Secondary storage: It is also known as auxiliary storage. It has huge storage capacity
and the storage is permanent. Usually we store data, programs and information in the
secondary storage, but we have to give instruction explicitly for this. Hard disk, CDs,
DVDs, memory sticks, etc. are some examples.

Comparison of Memories:

Input devices: These devices feed data and instructions from the user into the computer.

Output devices: These devices present information from a computer system to the user.

Keyboard: Allows the user to input text data consisting of alphabets, numbers and other
characters.

Mouse: A small handheld device used to position the cursor or move the pointer on the
computer screen by rolling it over a mouse pad / flat surface.

Light pen: A pointing device shaped like a pen. Has the advantage of ‘drawing’ directly onto
the screen.

Touch screen: Allows the user to operate/make selections by simply touching on the display
screen.

Graphic tablet: Consists of an electronic writing area and a special ‘pen’ that works with it.
Allows artists to create graphical images with actions similar to traditional drawing tools.

Joystick: Used to play video games, control training simulators and robots.

Microphone: Accepts sound in analogue nature as input and converts it to digital format.

Scanner: Allows capturing of information, like pictures or text and converting it into a digital
format that can be edited using a computer.

OMR: Scanning device that reads predefined positions and records where marks are made
on the printed form. Useful for applications such as objective type tests and questionnaires.

Bar Code Reader: A bar code is a set of vertical lines of different thicknesses and spacing
that represent a number. Barcode readers are used to input data from such set of barcodes.
7
Computer Science - XI
QR (Quick Response) code is similar to barcodes. Barcodes are single dimensional where as
QR codes are two dimensional. The QR code can be read using a barcode reader or a mobile
with a camera and special software installed.
Biometric sensor: Identifies unique human physical features like fingerprints, retina, iris
patterns, etc. to identify, verify and authenticate the identity of the user.

Smart card reader: These are used to access data in a smart card. Smart card is a plastic
card that stores and transacts data. Used in banking, healthcare, telephone calling,
electronic cash payments and other applications.

Digital camera: Takes pictures and videos and converts it to the digital format. Web camera
is a compact and less expensive version of a digital camera.

Monitor: Display devices include CRT monitors, LCD monitors, TFT monitors, LED monitors,
gas plasma monitors, Organic Light Emitting Diode (OLED) Monitors, etc.

LCD projector: An LCD projector is a type of video projector for displaying video, images or
computer data on a large screen or other flat surface.
Printer: Used to produce hardcopy output. The output printed on paper is known as
hardcopy. Classified as Impact or Non-impact printers. Dot-matrix uses impact mechanism.
It can print carbon copies with less printing cost. These printers are slow and noisy. Inkjet
printers are non-impact printers that form the image on the page by spraying tiny droplets
of ink from the print head. Ink jet printers are inexpensive, but the cost of ink cartridges
makes them costly. Laser printers are non-impact printers that produce good quality
images. Monochrome and colour laser printers are available. Laser printers are faster and
their speed is rated in pages per minute (ppm). Thermal printer is a non-impact printer that
produces a printed image by selectively heating heat sensitive thermal paper when it passes
over the thermal print head. It is popular as a portable printer.

Plotter: A plotter is an output device used to produce hardcopies of graphs and designs on
the paper.

3D printer: A 3D printer is an output device used to print 3D objects. It can produce


different kinds of objects, in different materials, using the same printer.

e-Waste: Electronic waste may be defined as discarded computers, office electronic


equipment, entertainment devices, mobile phones, television sets and refrigerators. The
used electronics which are destined for reuse, resale, salvage, recycling or disposal are also
considered as e-waste.

e-Waste disposal methods: Re-use, incineration (combustion process in which the waste is
burned in incinerators at a high temperature), recycling, (the process of making new
products from a product that has originally served its purpose) and land filling.

Software: A general term used to denote a set of programs that help us to use the computer
system. Two types - system software, application software.

8
Computer Science - XI

System software: A set of programs which aids in the execution of a general user’s
computational requirements on a computer system. The components of system software
are Operating system, Language processors and Utility software.

Operating system (OS): A set of programs that acts as an interface between the user and
computer hardware. It controls and co-ordinates the operations of a computer. It acts as the
resource manager of the computer system.

Function of OS: Process management, memory management, file management, device


management, security management and command interpretation.

Computer languages: Broadly classified into low level languages and high level languages.
Machine language and assembly language are the different low level languages. The
language, which uses binary digits 0 and 1, is called machine language. Assembly language
use mnemonics. Mnemonic is a symbolic name given to an operation. High Level Languages
are like English languages and are simpler to understand.

Language processors: These are the system programs that translate programs written in
high level language or assembly language into its equivalent machine language.

Types of language processors: Assembler (translates the program code written in assembly
language to machine language), Interpreter (converts a HLL program into machine language
line by line) and Compiler (translates a program written in high level language into machine
language).
Utility software: A set of programs which help users in system maintenance tasks. Some of
them are compression tools, disk defragmenter, backup software and antivirus software

Compression utility: Large files can be compressed so that they take less storage area.
These compressed files can be decompressed into its original form when needed.
Compression of files is known as zipping and decompression is called unzipping. WinZip,
WinRAR, etc. are examples.

Disk defragmenter: A program that rearranges files on a computer hard disk. This enables
the computer to work faster and more efficiently.

Backup utility: These programs facilitate the backing up of disk.

Antivirus programs: A utility program that scans the computer system for viruses and
removes them. Norton Antivirus, Kaspersky, etc. are examples.

General purpose software: These are used to perform tasks in a particular application area.
General purpose software is classified as word processors, spreadsheet software,
presentation software, database software and multimedia software.

Word processing software: It is designed for creating and modifying documents. It helps to
create, edit, format and print textual matters easily. Formatting features include different
font settings, paragraph settings, bullets and numbering, alignments and more. In addition

9
Computer Science - XI
to this it can check spelling and grammar in the document, insertion of pictures, charts and
tables. We can specify headers and footers for every page in the document. The most

popular examples of this type of software are MS Word, Open Office Writer, Apple iWork
Pages, etc.
Spreadsheet software: This software allows users to perform calculations using
spreadsheets. It also allows us to insert drawing objects in the worksheet and create
different types of charts for graphical representation of numerical data. Microsoft Excel,
Open Office Calc, Lotus 1-2-3 and Apple iWork Numbers are some examples of spreadsheet
software.

Presentation software: The software is used to display information in the form of a slide
show. Presentation software allows preparing slides containing pictures, text, animation,
video and sound effects. Microsoft PowerPoint, Apple iWork Keynote and Open Office
Impress are examples for presentation software.

Database software: Database is an organised collection of data arranged in tabular form.


Database Management System (DBMS) consists of a collection of interrelated data and a set
of programs to access those data. They provide privacy and security to data and enforce
standards for data. Examples of DBMS software are Microsoft Access, Oracle, Postgres SQL,
My SQL, etc.

Multimedia software: Multimedia is the integration of multiple forms of media. This


includes text, graphics, audio, video, etc. Some multimedia software allows users to create
and edit audio and video files. Audio converters, audio players and video editing software
are some forms of multimedia software. Examples are VLC Player, Adobe Flash, Real Player,
Media Player, etc.

The Free Software Foundation (FSF) defines the four freedoms for free and open source
software:
Freedom 0 : The freedom to run program for any purpose.
Freedom 1 : The freedom to study how the program works and adapt it to your
needs. Access to source code should be provided.
Freedom 2 : The freedom to distribute copies of the software.
Freedom 3 : The freedom to improve the program and release your improvements
to the public, so that the whole community benefits.

Freeware Vs Shareware:

1
0
Computer Science - XI
Questions from Previous Years’ Question Papers
1. Which one of the following is NOT a free and open source software?
a) GNU/Linux b) MS Office c) GIMP d) Mozilla Firefox (1) (July 2017)
2. Which among the following is NOT a recommended method for e-Waste disposal?
a) Reuse b) Incineration c) Land filling d) Recycling (1) (July 2017)
3. What do you mean by data processing? Describe the various activities involved in data
processing. (5) (July 2017)
4. (a) Write the following memory devices in the order of their speed (fastest to slowest
order)
(i) Cache (ii) RAM (iii) Hard Disk (iv) Registers (1) (March 2017)
(b) What do you mean by Freeware and Shareware? (1) (March 2017)
5. With the help of a block diagram, explain the functional units of a computer.
(5) (March 2017)
6. Which register holds the memory address of next instruction to be executed?
a) Accumulator b) PC c) MBR d) MAR (1) (Sept. 2016)
7. Differentiate shareware software and free software. (2) (Sept. 2016)
8. What do you mean by e-waste? Explain the role of students in e-waste disposal.
(2) (Sept. 2016)
9. If Tracks and Sectors : Hard disk, then : Compact Disk (1) (March 2016)
10. Pick out the software which rearranges the scattered files in the hard disk and improves
the performance of the system.
(a) Backup software (b) File compression software
(c) Disk defragmenter (d) Antivirus software (1) (March 2016)
11. Describe the different types of memories and memory devices in computer with
features and examples. (5) (March 2016)
12. Which software is used for calculation?
a) Word processor b) Spread sheet c) Presentation d) Multimedia
(1) (Sept. 2015)
13. Accumulator stores ………………
a) address of data b) instruction to be executed
c) address of next instruction to be executed d) intermediate results
(1) (Sept. 2015)
14. To use a computer not only the hardware but also software is required. Explain the
classification of software. (5) (Sept. 2015)
15. (a) What do you mean by cache memory? (1) (March 2015)
(b) Write the names of the figures given below: (1) (March 2015)
16. Explain how e-waste creates environmental and health problems. What are the
different methods for e-waste disposal? Which one is the most effective in your point of
view? Why? (5) (March 2015)

1
1
Computer Science - XI

Chapter 4 – Principles of Programming and Problem Solving

Computer program: A sequence of instructions given to a computer to solve a problem.


Program instruction: It is an action oriented statement and it tells the computer what
operation it should perform.
Top down design: It is the process of solving a complex problem by breaking it down into
different tasks and solving each task from main to sub.
Bottom up design: It is the process of breaking a complex problem into smaller sub tasks
and solving each task from sub to main.
Stages of problem solving: (i) Problem identification (ii) Preparing algorithms and flowcharts
(iii) Coding the program using programming language (iv) Translation (v) Debugging (vi)
Execution and Testing and (vii) Documentation
Algorithm: It is a step-by-step procedure to solve a problem, where each step represents a
specific task to be carried out.
Flowchart: The pictorial representation of an algorithm with specific symbols for
instructions and arrows showing the sequence of operations.

Flowchart Symbols: Start/Stop Input / Output Process Decision

Flow lines Connectors

Advantages of flowcharts: Better communication, Effective analysis, Effective synthesis,


Efficient coding.
Translation: It is the process of converting a program written in high level language into its
equivalent version in machine language.
Debugging: It is the process of detecting and correcting the errors in a program.
Syntax errors: The errors occur when the rules or syntax of the programming language are
not followed. Such program errors typically involve incorrect punctuation, incorrect word
sequence, undefined term, or illegal use of terms or constructs.
Logical error: It is due to improper planning of the program's logic and revealed during the
execution of the program.
Run time error: These errors occur unexpectedly when computer becomes unable to
process some improper data.
Documentation: An on-going process of documenting the code that starts in the problem-
study phase of the system and continues till its implementation and operation. Internal
documentation is done through comments in programs. Various manuals provide external
documentation.

1
Computer Science - XI
Questions from Previous Years’ Question Papers
1. Which one of the following statements is INCORRECT?
a) Syntax error occurs due to violation of rules of the programming language.
b) Incorrect punctuation is an example of syntax error.
c) Language processors detect syntax error during translation.
d) Language processor translates source code into machine code even if syntax error is
present in the program. (1) (July 2017)
2. Write an algorithm to check whether a given integer is even or odd. (2) (July 2017)
3. Draw a flowchart to compute average of three numbers. (2) (July 2017)
4. Write different types of program documentation with their importance.
(3) (July 2017)
5. Pick the odd one out and give reason for your finding.
a) b) c)

(1) (March 2017)

6. Write an algorithm to print the numbers up to 100 in reverse order. That is, the output
should be 100, 99, 98, 97, ……, 1. (2) (March 2017)

7. Draw a flowchart to check whether the given number is positive, negative or zero.
(2) (March 2017)

8. “It is better to give proper documentation within the program”. Give a reason.
(3) (March 2017)

9. Which one of the following errors is identified at the time of compilation?


a) Syntax error b) Logical error c) Run-time error d) All of these
(1) (Sept. 2016)
10. Consider the following algorithm and answer the following questions:
Step 1: Start
Step 2: N=2, S=0
Step 3: Repeat Steps 4 and 5 while N<=10
Step 4: S=S+N
Step 5: N=N+2
Step 6: Print S
Step 7: Stop
a) Predict the output of the above algorithm. (1)
b) Draw a flowchart for the above algorithm. (3) (Sept. 2016)
11. Make a flowchart using the given labeled symbols, for finding the sum of all even
numbers upto ‘N’. (3) (March 2016)

2
Computer Science - XI

12. Write an algorithm to accept an integer number and print the factors of it.
(3) (March 2016)
13. Ramesh has written a C++ program. During compilation and execution there were no
errors. But he got a wrong output. Name the type of error he faced. (1) (March 2016)
14. Differentiate between top down design and bottom up design in problem solving.
(2) (March 2016)
15. ....... is the stage where programming errors are discovered and corrected.
(1) (Sept. 2015)
16. Write an algorithm to input the scores obtained in three unit tests and find the average
store. (2) (Sept. 2015)
17. Draw the flowchart to find the sum of first N natural numbers. (3) (Sept. 2015)

3
Computer Science - XI
18.

Explain the flowchart and predict the output. (2) (Sept. 2015)
19. Some of the components in the phases of programming are given below. Write them in
order of their occurrence.
(a) Translation (b) Documentation
(c) Problem identification (d) Coding of a program (1) (March 2015)
20. Define the term debugging. Write the names of two phases that are included in
debugging. (2) (March 2015)
21. Define the different types of errors that are encountered during the compilation and
running of a program. (2) (March 2015)
22. Draw a flowchart to input ten different numbers and find their average.
(3) (March 2015)

4
Computer Science - XI

Chapter 5: Introduction to C++ Programming

Character set: The fundamental unit of C++ language. The character set of C++ is
categorized as (i) Letters (A – Z, a – z), (ii) Digits (0 – 9), (iii) Special characters (iv)White
spaces.

Tokens: The fundamental building blocks of the program. C++ has five types of tokens –
Keywords, Identifiers, Literals, Punctuators and Operators.

Keywords: The words (tokens) that convey a specific meaning to the language compiler.
These are also known as reserved words.

Identifiers: These are the user-defined words used to name different program elements
such as memory locations, statements, functions, objects, classes etc. The identifiers of
memory locations are called variables. The identifiers assigned to statements are called
labels. The identifiers used to refer a set of statements are called function names.

Rules for naming identifiers: An arbitrary long sequence of letters, digits and underscores.
The first character must be a letter or underscore ( _ ). White space and special characters
are not allowed. Keywords cannot be used. Upper and lower case letters are treated
differently.

Literals: Data items that never change their value during the program run. They are often
referred to as constants. Literals are of four types – Integer literals, Floating point literals,
Character literals and String literals.

Integer literals: The tokens constituted only by digits. They are whole numbers without
fractional part. Eg: 13. -76

Floating point literals: Also known as real constants. These are numbers having fractional
parts. These can be written in one of the two forms –fractional form or exponential form.
Eg: 4.35, 2.5e6, -5E-3 etc.

Character literal: A single character enclosed in single quotes. Eg: ‘a’, ‘9’, ‘+’ etc.

Escape sequences: These special character constants that represent non-graphic symbols. It
consists of a backslash (\) followed by one or more specific characters.

String constant: A sequence of one or more characters enclosed within a pair of double
quotes is called. Eg: “Hello friends”, “123” etc.

Punctuators: Some special symbols that have syntactic or semantic meaning to the
compiler.
Operator: A symbol that tells the compiler about a specific operation. They are the tokens
that trigger some kind of operation. The operator is applied on a set of data called
operands.
1
5
Computer Science - XI
Questions from Previous Years’ Question Papers
1. Identify and classify tokens in the following C++ statement:
cout << “The Missile Man”; (2) (July 2017)
2. Identify the invalid literals from the following and write reason for each:
a) 2E3.5 b) “9” c) ‘hello’ d) 55450 (2) (March 2017)
3. Which of the following is a user-defined name?
a) Keyword b) Identifier c) Escape sequence d) All of these
(1) (Sept. 2016)
4. Identify whether the following are valid identifiers or not. If not, give reason.
a) Break b) Simple.interest (2) (Sept. 2016)
5. What is preprocessor directive statement? Explain with an example. (2) (Sept. 2016)
6. Some of the literals in C++ are given below. How do they differ?
(5, ‘5’, 5.0, “5”) (2) (March 2016)
7. A student wants to insert his name and school address in the C++ program that he has
written. But this should not affect the compilation or execution of the program. How is
it possible? Give an example. (2) (March 2016)
8. The following are some invalid identifiers. Specify its reason.
a) Sum of digits b) 1year c) First.jan d) for (2) (Sept.2015)
9. Mention the purpose of tokens in C++. Write names of any four tokens in C++.
(2) (March 2015)

2
Computer Science - XI

Chapter 6: Data Types and Operators

Data types: These are the means to identify the nature of the data and the set of operations
that can be performed on the data.

Fundamental data types: These are the built-in data types of C++. Also known as basic data
types or atomic data types. The five fundamental data types in C++ are char, int, float,
double and void.

Data type modifiers: The keywords used to alter the size, range or precision of data
supported by the basic data types. Important modifiers are signed, unsigned, long and short.

Variables: The names given to memory locations, by which data in these


locations are referenced. In the figure, the variable name is Num and it
consumes two bytes of memory at memory addresses 1001 and 1002. The
content of this variable is 18. That is the L-value of Num is 1001 and the R-value is 18.

Operators: The tokens or symbols that trigger computer to carry out operations. The data
on which an operation are called operands. An operand may be either a constant or a
variable. Classified into three –unary, binary and ternary.

Arithmetic operators: Used to perform basic arithmetic operations such as addition,


subtraction, multiplication and division.

Modulus operator (%): Also called as mod operator. It gives the remainder value during
arithmetic division.

Relational operators: Used for comparing numeric data. These are binary operators. The
result of any relational operation will be either True or False.

Expression: Composed of operators and operands. Classified into arithmetic expressions,


relational expressions and logical expressions.

Arithmetic expression: An expression in which only arithmetic operators are used. Further
classified into integer expressions and floating point (real) expressions.

Integer expression: An arithmetic expression that contains only integer operands and
produces an integer result after performing all the operations given in the expression.

Floating point or real expression: An arithmetic expression that contains only floating point
data and returns a floating point result after performing all the operations given in the
expression.

Relational expression: An expression that contains relational operators. It produces Boolean


type results like True (1) or False (0).

Logical expressions: An expression that uses logical operators to combine two or more
relational expressions. It produces either True or False as the result.
1
Computer Science - XI
Type conversion: Conversion of the data type of an operand into another type. Done in two
ways: implicitly and explicitly.
Type promotion: It is the implicit type conversion is performed by C++ compiler internally.
C++ converts the lower sized operands to the data type of highest sized operand. The
conversion is always from lower type to higher and hence the name type promotion.

Type casting: It is the explicit type conversion and is done by the programmer by specifying
the data type within parentheses to the left of the operand.

Variable declaration: data_type <variable1>,<variable2>, <variable3>,...;

Variable initialisation: Supplying value to a variable at the time of its declaration. Syntax:
data_type variable = value;

const access modifier: The keyword const is used to create symbolic constants whose value
can never be changed during execution. Eg: const float pi=3.14; the value of pi remains
constant (unaltered) throughout the execution of the program.

C++ Statements Operator Requirements Example


Input Statement >> cin and a variable cin>> a;
cout << a;
cout and variable or cout << “hello”;
Output Statement <<
constant or expression cout << 25;
cout << a + 2;
A variable and data N = 5;
Assignment
= (constant / variable / N = a;
Statement
expression) Num = a + 5;

Pre-processors: These are the compiler directive statements which give instruction to the
compiler to process the information provided before actual compilation starts. These lines
always start with a # (hash) symbol.

Header files: Files available along with compiler and they are kept in the standard library.
The header files contain the information about functions, objects and predefined derived
data types.

using namespace statement: It tells the compiler about a namespace where it should
search for the elements used in the program. In C++, std is an abbreviation of 'standard' and
it is the standard namespace in which cout, cin and a lot of other things are defined. So,
when we want to use them in a program, we need to follow the format std::cout and
std::cin. This kind of explicit referencing can be avoided with the statement using
namespace std; in the program.

main() function: An essential function in every C++ program. The execution starts at main()
and ends within main().

2
Computer Science - XI
Questions from Previous Years’ Question Papers

1. Write output of the following C++ program.


#include<iostream>
using namespace std;
int main()
{
int a=1, b=2, c=3;
cout << a+b+c/3;
cout << “\n”;
cout << (a+b)%c;
} (2) (July 2017)
2. Write value returned by the following C++ expressions if x=10 and y=20.
a) x>15 ||y>15 b) x>15 && y>15 c) !(x>y) (3) (July 2017)
3. The following C++ code segment is a part of a program written by Smitha to find the
average of 3 numbers.
int a,b,c;
float avg;
cin >>a>>b>>c;
avg=(a+b+c)/3;
cout<<avg;
What will be the output if she inputs 1, 4 and 5? How can you correct it?
(2) (March 2017)
4. Briefly explain the three components in the structure of a C++ program.
(3) (March 2017)
5. Write C++ example for the following:
a) Declaration statement
b) Assignment statement
c) Type casting (3) (Sept. 2016)
6. Write a C++ expression to calculate the value of the following equation:

(2) (Sept. 2015)


7. Explain the data types in C++. (3) (Sept. 2015)
8. Predict the output of the following C++ statements:
int a=-5, b=3, c=4;
c+= a++ + --b;
cout<<a<<b<<c; (3) (March 2015)

9. Raju wants to add value 1 to the variable ‘p’ and store the new value in ‘p’ itself. Write
four different statements in C++ to do the task. (2) (March 2015)

3
Computer Science - XI
10. Match the following: (3) (March 2015)
Name Symbol
(a) Modulus operator (i) ++
(b) Logical operator (ii) ==
(c) Relational operator (iii) =
(d) Assignment operator (iv) ?:
(e) Increment operator (v) &&
(f) Conditional operator (vi) %

4
Computer Science - XI
Chapter 7: Control Statements

Selection Statements
The statements provided by C++ for the selected execution of some statements are called
decision making statements or selection statements. if and switch are the two types of
selection statements in C++. The selection will be based on conditions. The conditions are
formed by relational or logical expressions.
if statement
The if statement is used to select a set of statements for execution based on a condition.
In C++, conditions (otherwise known as test expressions) are provided by relational or
logical expressions. The syntax (general form) of if statement is as follows:
if (test expression)
{
statement block;
}

Here the test expression represents a condition which is either a relational


expression or logical expression. If the test expression evaluates to True (non-zero value), a
statement or a block of statements associated with if is executed. Otherwise, the control
moves to the statement following the if construct.
if – else statement
The syntax is:
if (test expression)
{
statement block 1;
}
else
{
statement block 2;
}
If the test expression evaluates to True, only the statement block 1 is executed. If
the test expression evaluates to False statement block 2 is executed.
When we write an if statement inside another if block, it is called nesting.
The else if ladder
When we want to select one action from more than two actions, different conditions will be
given and each condition will decide which statement is to be selected for execution. For
this, we can use else if ladder, also referred to as the else if staircase because of its
appearance. It is also known as if...else if statement. The general form of else if
ladder is:
if (test expression 1)
statement block 1;
else if (test expression 2)
statement block 2;
else if (test expression 3)
statement block 3;
...............
1
Computer Science - XI
else
statement block n;
At first, the test expression 1 is evaluated and if it is True, the statement block 1
is executed and the control comes out of the ladder. That means, the rest of the ladder is
bypassed. If test expression 1 evaluates to False, then the test expression 2 is
evaluated and so on. If any one of the test expressions evaluates to True, the corresponding
statement block is executed and control comes out of the ladder. If all the test expressions
are evaluated to False, the statement block n after the final else is executed.

switch statement
We have seen the concept of multiple branching with the help of else if ladder. Some of
these programs can be written using another construct of C++ known as switch statement.
This selection statement successively tests the value of a variable or an expression against a
list of integers or character constants. The syntax of switch statement is as follows:
switch(expression)
{
case constant_1 : statement block 1;
break;
case constant_2 : statement block 2;
break;
case constant_3 : statement block 3;
break;
:
:
case constant_n-1 : statement block n-1;
break;
default : statement block n;
}
In the syntax switch, case, break and default are keywords. The expression is evaluated to
get an integer or character constant and it is matched against the constants specified in the case
statements. When a match is found, the statement block associated with that case is executed until
the break statement or the end of switch statement is reached. If no match is found, the
statements in the default block get executed. The default statement is optional and if it is
missing, no action takes place when all matches fail.
The following are the requirements to implement a multi branching using switch statement:
• Conditions involve only equality checking. In other cases, it should be converted into
equality expression.
• The first operand in all the equality expressions should be the same variable or
expression.
• The second operand in these expressions should be integer or character constants.

2
Computer Science - XI

The conditional operator (?:)


C++ has a ternary operator. It is the conditional operator (?:) consisting of the symbols ?
and : (a question mark and a colon). It requires three operands. It can be used as an
alternative to if...else statement. Its general form is:
Test expression ? True_case code : False_case code;
Test expression can be any relational or logical expression and True_case code and
False_case code can be constants, variables, expressions or statement. The operation
performed by this operator is shown below with the help of an if statement.
if (Test expression)
{
True_case code;
}
else
{
False_case code;
}

Looping (Iteration) Statements


Four elements of a loop:
1. Initialisation: The loop control variable (Variable used in the condition) gets its first
value. The initialisation statement is executed only once, at the beginning of the loop.
2. Test expression: It is a relational or logical expression whose value is either True or
False. It decides whether the loop-body will be executed or not. If the test expression
evaluates to True, the loop-body gets executed, otherwise it will not be executed.
3. Update statement: The update statement modifies the loop control variable by
changing its value. The update statement is executed before the next iteration.
4. Body of the loop: The statements that need to be executed repeatedly constitute the
body of the loop.

3
Computer Science - XI
while statement
It is an entry-controlled loop. The condition is checked first and if it is True the body of the
loop will be executed. That is the body will be executed as long as the condition is True. The
syntax of while loop is:
initialisation of loop control variable;
while(test expression)
{
body of the loop;
updation of loop control variable;
}
for statement
It is also an entry-controlled loop in C++. All the three loop elements (initialisation, test
expression and update statement) are placed together in for statement. The syntax is:
for (initialisation; test expression; update statement)
{
body-of-the-loop;
}
do...while statement
In the case of for loop and while loop, the test expression is evaluated before executing
the body of the loop. If the test expression evaluates to False for the first time itself, the
body is never executed. Its syntax is :
initialisation of loop control variable;
do
{
body of the loop;
updation of loop control variable;
} while(test expression);

Placing a loop inside the body of another loop is called nesting of a loop. When we nest two
loops, the outer loop counts the number of completed repetitions of the inner loop. Here
the loop control variables for the two loops should be different.

4
Computer Science - XI
Questions from Previous Years’ Question Papers

1. Which one of the following is NOT an iteration statement in C++?


a) while b) continue c) for d) do … while (1) (July 2017)
2. Write an output of the following C++ statements.
int p=1;
for (int n= –5; n<=5; n++)
p = p * n;
cout<<p;

a) 25 b) 0 c) -25 d) None of these (1) (July 2017)


3. What is the use of jump statements in a program? Explain the different types of jump
statements available in C++. (5) (July 2017)
4. Write a C++ program that accepts a list of integers as input and print sum of even
integers in the list. (5) (July 2017)
5. a) Name the type of loop which can be used to ensure that the body of the loop will
surely be executed at least once. (1) (March 2017)
b) Consider the code given below and predict the output:
for (int i=1; i<=9; i=i+2)
{
if (i==5) continue;
cout<<i<<” “;
} (1) (March 2017)

6. Write a program to check whether the given number is palindrome or not.


(5) (March 2017)

7. Write a program to print the leap years between 2000 and 3000. (5) (March 2017)
8. Which one of the following C++ commands transfer the program control to a labeled
statement?
a) for b) while c) break d) goto (1) (Sept. 2016)

9. Write C++ program for getting the following output:


1
1 2
1 2 3
1 2 3 4 (3) (Sept. 2016)

10. Consider the following C++ program and answer the following questions:
#include<iostream>
using namespace std;
int main()
{
int a, p=1;
5
Computer Science - XI
for (a=1; a<=5; a+=2)
P=p*a;
cout<<p;
}

a) Predict the output of the above code. (1)

b) Rewrite the above code using while loop. (2) (Sept. 2016)

11. How many times the following loop will execute?


int m = 2;
do
{
cout<<“ Welcome”;
m++;
}while (m>10); (1) (March 2016)
12. Consider the following statements in C++:
if (mark>=18)
cout<< “Passed”;
else
cout<< “Failed”;
Suggest an operator in C++ using which the same output can be produced.
(1) (March 2016)
13. Write a C++ program to accept an integer number and check whether it is an Armstrong
number or not. (Hint: Sum of the cubes of the digits of an Armstrong number is equal to
that number itself.) (5) (March 2016)
14. Write a C++ program to accept an integer number and print its reverse. (Hint: If 234 is
given, the output must be 432.) (5) (March 2016)
15. Which selection statement tests the value of a variable or an expression against a list of
integer or character constants?
a) for b) if c) switch d) Conditional expression (1) (Sept. 2015)

16. ……… is an entry controlled loop. (1) (Sept. 2015)


17. Write a C++ program to display the roots of quadratic equation. (5) (Sept. 2015)
18. Write a C++ program to display Fibonacci series. (5) (Sept. 2015)
19. (a) statement takes the program control out of the loop even though the test
expression is true. (1) (March 2015)
b) Consider the following code fragment. How many times will the character ‘*’ be
printed on the screen?
for (i=0; i<10; i=i+2);
{
cout<< ‘*’;
} (1) (March 2015)
6
Computer Science - XI

20. Write a program to do the following:


(a) Input the values for variables n and m.
(b) Print the numbers between 1 and n which are exactly divisible by m.
(c) Checks whether the numbers divisible by m are odd or even. (5) (March 2015)
21. Write a program using nested loop that inputs a number n which generates an output
as follows:
Hint: If the value of n is 5, the output will be as

25
25 16
25 16 9
25 16 9 4
25 16 9 4 1 (5) (March 2015)

7
Computer Science - XI
Chapter 8: Arrays
An array is a collection of elements of the same type placed in contiguous memory
locations. Arrays are used to store a set of values of the same type under a single variable
name. Each element in an array can be accessed using its position in the list called index
number or subscript.
The syntax for declaring an array in C++ is as follows.
data_type array_name[size];
Eg: int num[10];
This statement declares an array named num that can store 10 integer numbers.
For a single dimensional array, the total size allocated can be computed using the following
formula:
total_bytes = sizeof(array_type) × size_of_array
The array in the above example require 4 x 10 = 40 Bytes
Array elements can be initialised in their declaration statements in the same manner as in
the case of variables, except that the values must be included in braces, as shown in the
following example:
int score[5] = {98, 87, 92, 79, 85};
Algorithm for selection sort
Step 1. Start
Step 2. Accept a value in N as the number of elements of the array
Step 3. Accept N elements into the array AR
Step 4. Repeat Steps 5 to 9, (N – 1) times
Step 5. Assume the first element in the list as the smallest and store it in MIN and its
position in POS
Step 6. Repeat Step 7 until the last element of the list
Step 7. Compare the next element in the list with the value of MIN. If it is found smaller,
store it in MIN and its position in POS
Step 8. If the first element in the list and the value in MIN are not the same, then swap
the first element with the element at position POS
Step 9. Revise the list by excluding the first element in the current list
Step 10. Print the sorted array AR
Step 11. Stop

Algorithm for bubble sort


Step 1. Start
Step 2. Accept a value in N as the number of elements of the array
Step 3. Accept N elements into the array AR
Step 4. Repeat Steps 5 to 7, (N - 1) times
Step 5. Repeat Step 6 until the second last element of the list
Step 6. Starting from the first position, compare two adjacent elements in the list. If
they are not in proper order, swap the elements.
Step 7. Revise the list by excluding the last element in the current list.
Step 8. Print the sorted array AR
Step 9. Stop
1
Computer Science - XI
Algorithm for Linear Search
Step 1. Start
Step 2. Accept a value in N as the number of elements of the array
Step 3. Accept N elements into the array AR
Step 4. Accept the value to be searched in the variable ITEM
Step 5. Set LOC = -1
Step 6. Starting from the first position, repeat Step 7 until the last element
Step 7. Check whether the value in ITEM is found in the current position. If found then
store the position in LOC and Go to Step 8, else move to the next position.
Step 8. If the value of LOC is less than 0 then display "Not Found", else display the
value of LOC + 1 as the position of the search value.
Step 9. Stop
Algorithm for binary search
Step 1. Start
Step 2. Accept a value in MAX as the number of elements of the array
Step 3. Accept MAX elements into the array LIST
Step 4. Accept the value to be searched in the variable ITEM
Step 5. Store the position of the first element of the list in FIRST and that of the last in
LAST
Step 6. Repeat Steps 7 to 11 While (FIRST <= LAST)
Step 7. Find the middle position using the formula (FIRST + LAST)/2 and store it in
MIDDLE
Step 8. Compare the search value ITEM with the element at the MIDDLE of the list
Step 9. If the MIDDLE element contains the search value ITEM then stop search, display
the position and go to Step 12.
Step 10. If the search value is smaller than the MIDDLE element
Then set LAST = MIDDLE - 1
Step 11. If the search value is larger than the MIDDLE element
Then set FIRST = MIDDLE + 1
Step 12. Stop

Two dimensional (2D) arrays


A two dimensional array is an array in which each element itself is an array. For instance, an
array AR[m][n] is a 2D array containing m rows and n columns.
The general form of a two dimensional array declaration in C+ + is as follows :
data_type array_name[rows][columns];
where data_type is any valid data type of C++ and elements of this 2D array will be of this
type. The rows refers to the number of rows in the array and columns refers to the
number of columns in the array. The indices (subscripts) of rows and columns, start at 0 and
ends at (rows–1) and (columns–1) respectively. The following declaration declares an array
named marks of size 5 × 4 (5 rows and 4 columns) of type integer.
int marks[5][4];

2
Computer Science - XI
Questions from Previous Years’ Question Papers

1. An array is declared as follows:


int a[5] = {1, 2, 3, 4, 5};
What will be the value of a[2] + a[3]?
a) 7 b) 5 c) 6 d) 4 (1) (July 2017)
2. Write C++ statements to double each element of the array int A[100].
(2) (July 2017)
3. Consider an array A with the following elements sorted in ascending order.
5, 9, 10, 13, 16, 17, 19, 20, 25, 37
Explain the working of binary search algorithm to search 25. How many comparisons
are required for this searching? (3) (July 2017)
4. Find the value of score[4] based on the following declaration statement:
int score[5] = {98, 87, 92, 79, 85}; (1) (March 2017)

5. Suppose M[5][5] is a 2D array that contains the elements of a square matrix. Write C++
statements to find the sum of the diagonal elements. (2) (March 2017)
6. Write an algorithm for arranging elements of an array in ascending order using bubble
sort. (3) (March 2017)
7. ………………. search method is an example for ‘divide and conquer method’.
(1) (Sept. 2016)
8. What is an array? Write C++ program to declare and use a single dimensional array for
storing the computer science marks of all students in your class. (3) (Sept. 2016)
9. a) Write C++ program for sorting a list of numbers using Bubble sort method. (2)
b) Write different passes of sorting the following numbers using Bubble sort:
32, 21, 9, 17, 5 (2) (Sept. 2016)

10. Declare a two dimensional array to store the elements of a matrix with order 3 x 5.
(1) (March 2016)

11. Define an array. Also write an algorithm for searching an element in the array using any
one method that you are familiar with. (3) (March 2016)
12. int num[10];
The above C++ statement declares an array named num that can store maximum ….
integer location.
a) 9 b) 10 c) N d) none of these (1) (Sept. 2015)
13. Explain the memory allocation for the following declaration statement.
int A[10][10]; (2) (Sept. 2015)

14. Write a C++ program to illustrate array traversal. (3) (Sept. 2015)
15. Read the following C++ statement:
int MAT[5][4];

3
Computer Science - XI
(a) How many bytes will be allocated for this array? (1) (March 2015)
(b) Suppose MAT[4][4] is a 2D array that contains the elements of a square matrix.
Write C++ statements to find the sum of all the elements in the array.
(2) (March 2015)

16. Write the names of two searching methods in arrays. Prepare a chart that shows the
comparison of two searching methods. (3) (March 2015)

4
Computer Science - XI

Chapter 9: String Handling and I/O Functions

A character array can be used to store a string, since it is a sequence of characters. The array
char my_name[10]; can store a string of 9 characters. One location will be used to store
‘\0’ (null character) as string terminator.
A string can be input using the statement:

cin >> my_name;

This statement can store a string without any white space (that is, only one word). If we
want store strings containing white spaces (strings having more than one word) we can use
gets() function, getline() function or get() function.
Similarly to display string data we can use puts() function and write(0 function.
There are functions to perform input output operation on characters also. The table shows
them:

Console functions Stream functions


Type of data Operation
(stdio.h header file) (iostream.h header file)

Character getchar() cin.get() Character input


functions
putchar() cout.put() Character output

String gets() cin.getline(), cin.get() String input


functions
puts() cout.write() String output

Questions from Previous Years’ Question Papers

1. Consider the following C++ program.


#include<iostream>
using namespace std;
int main()
{
char str[20];
cin>>str;
cout<<str;
}

What will be the output if we input the string “Vande Mataram”. Justify your answer.
(2) (July 2017)
2. What is the advantage of using gets() function in C++ program to input string data?
Explain with an example. (2) (March 2017)

1
Computer Science - XI

3. a) Write the declaration statement for a variable ‘name’ in C++ to store a string of
maximum length 30. (1)
b) Differentiate the statements cin>>name; and gets(name); for reading data to
the variable ‘name’. (1) (Sept. 2016)

4. Consider the following C++ statements:


char word[20];
cin>>word;
cout<<word;
gets(word);
puts(word);
If the string entered is “HAPPY NEW YEAR”, predict the output and justify your answer.
(2) (March 2016)

5. a) my_name is a variable contains a string. Write two different C++ statements to


display the string. (2)
b) …… function is used to copy a string to another variable. (1) (Sept. 2015)

6. Read the following code:


char str[30];
cin >> str;
cout << str;
If we give the input “Green Computing”, we get the output “Green”. Why is it so? How
can you correct that? (2) (March 2015)
Computer Science - XI

Chapter 10: Functions


The process of breaking large programs into smaller sub programs is called modularisation. The sub
programs are generally called functions.

Merits of modular programming


 Reduces the size of the program.
 Less chance of error occurrence.
 Reduces programming complexity.
 Improves reusability.

Function is a named unit of statements in a program to perform a specific task as part of the
solution.

Predefined functions
C++ provides a number of functions for various tasks. While using these functions, some of
them require data for performing the task assigned to it. We call them parameters or
arguments and are provided within the pair of parentheses of the function name. There are
certain functions which give results after performing the task. This result is known as value
returned by the function. Some functions do not return any value; rather they perform the
specified task.

Type Functions Syntax / Example Operation

strlen() strlen(string) To find the length of a string.

strcpy() strcpy(string1, string2) To copy one string into another


String Functions (string.h)

strcmp() strcmp(string1, string2) To compare two strings.


 Returns 0 if string1 and string2
are same.
• Returns a –ve value if string1 is
alphabetically lower than
string2.
 Returns a +ve value if string1 is
alphabetically higher than
string2.
To find the absolute value of an
Mathematical Functions

abs() abs(int)
integer.
sqrt() sqrt(double) To find the square root of a
number.
pow() pow(double, int) To find the power of a number. It
(math.h)

takes two arguments x and y.


Returns the value of xy.

1
Computer Science - XI

isupper() isupper(char) To check whether a character is in


upper case or not. The function
returns non-zero if the given character
is in uppercase, and 0 otherwise.
islower() islower(char) To check whether a character is in
lower case or not. The function
returns non-zero if the given character
is in lowercase, and 0 otherwise.
Character Functions (ctype.h)

isalpha() isalpha(char) To check whether a character is


alphabet or not. The function
returns non-zero if the given character
is an alphabet, and 0 otherwise.
isdigit() isdigit(char) To check whether a character is
digit or not. The function returns
non-zero if the given character is a
digit, and 0 otherwise.
isalnum() isalnum(char) To check whether a character is
alphanumeric or not. The function
returns non-zero if the given character
is alphanumeric, and 0 otherwise.
toupper() toupper(char c) This function is used to convert the
given character into its uppercase.
tolower() tolower(char c) This function is used to convert the
given character into its lowercase.
itoa() itoa(int n, char c[], int This function is used to convert an
len) integer value to string type. It
Conversion Function (stdlib.h)

requires three arguments. The first


one is the number to be converted.
The second argument is the
character array where the
converted string value is to be
stored and the last argument is the
size of the character array.
atoi() int atoi(char c[]); This function is used to convert a
string value to integer. It takes a
string as argument returns the
integer value of the string.
setw() char s[]="hello"; This function is used to set the
width for the subsequent string.
Function (iomanip.h)

cout<<setw(10)<<s The word hello will be displayed


I/O Manipulating

<<setw(10)<<"friends"; right aligned within a span of 10


The output of the given code character positions. Similarly, the
will be: word friends will also be displayed
hello friends right aligned within a span of 10
character positions.

2
Computer Science - XI

User defined functions

The syntax of a function definition is given below:


data_type function_name(argument_list)
{
statements in the body;
}
The data_type is any valid data type of C++. The function_name is a user-defined word
(identifier). The argument_list, which is optional, is a list of parameters, i.e. a list of
variables preceded by data types and separated by commas. The body comprises of C++
statements required to perform the task assigned to the function.

A function prototype is the declaration of a function by which compiler is provided with the
information about the function such as the name of the function, its return type, the
number and type of arguments, and its accessibility. The following is the format:
data_type function_name(argument_list);

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 arguments are known as
formal arguments. The constants, variables or expressions used in the function call are
known as actual (original) arguments. If variables are used in function prototype, they are
known as dummy arguments.
Two type of Function Calling

Recursion is the process of calling a function by itself and the function is known as recursive
function.

3
Computer Science - XI

Questions from Previous Years’ Question Papers

1. Which one of the following is NOT equal to others?


a) pow(64, 0.5) b) pow(2,3) c) sqrt(64) d) pow(3,2) (1) (July 2017)
2. Write a recursive C++ function that returns sum of the first n natural numbers.
(2) (July 2017)
3. List any three string functions in C++ and specify the value returned by them.
(3) (July 2017)
4. Name the built in function to check whether a character is alphanumeric or not.
(1) (March 2017)

5. Read the function definition given below. Predict the output, if the function is called as
convert(7);
void convert(int n)
{
if (n>1)
convert(n/2);
cout<<n%2;
} (2) (March 2017)
6. Explain the difference between call-by-value method and call-by-reference method with
the help of examples. (3) (March 2017)
7. Arguments used in call statement are formal arguments. State true or false.
(1) (Sept. 2016)

8. Differentiate the string functions strcmp() and strcmpi(). (2) (Sept. 2016)
9. Differentiate break and continue statements in C++. (2) (Sept. 2016)
10. Explain recursive function with the help of a suitable example. (3) (Sept. 2016)
11. Explain Call by Value and Call by Reference methods of function calling with the help of
suitable examples. (4) (Sept. 2016)
12. Suggest most suitable built-in function in C++ to perform the following tasks:
(a) To find the answer for 53.
(b) To find the number of characters in the string “KERALA”.
(c) To get back the number 10 if the argument is 100. (2) (March 2016)
13. A function can call itself for many times and return a result.
(a) What is the name given to such a function? (1)
(b) Write a function definition of the above type to find the sum of natural numbers
from 1 to N. (Hint: If the value of N is 5, the answer will be 1+2+3+4+5=15)
(3) (March 2016)

14. Explain two types of variable according to its scope and life. (2) (Sept. 2015)
15. Write a C++ Program to display the simple interest using function. (3) (Sept. 2015)

4
Computer Science - XI

16. The function which calls itself is called a . (1) (March 2015)
17. Construct the function prototype for the following functions:
(a) The function Display() accepts one argument of type double and does not return any
value.
(b) Total() accepts two arguments of type int, float respectively and return a float type
value. (2) (March 2015)
18. Name the different methods used for passing arguments to a function. Write the
difference between them with examples. (3) (March 2015)

5
Computer Science - XI

Chapter 11: Computer Networks


Computer network is a group of computers and other computing hardware devices.
Advantages: Resource sharing, Price-performance ratio, Communication, Reliability,
Scalability.
Data communication is the exchange of digital data between any two devices through a
medium of transmission.
Five basic elements of data communication system: Message, Sender, Receiver, Medium
and Protocol.
Communication channel or communication medium: The medium for data transmission
over a computer network.
Two types of communication media: Guided (wired) and unguided (wireless).
Guided media: physical wires or cables are used. Coaxial cable, twisted pair cable (Ethernet
cable) and optical fibre cable are examples.
Unguided media: Wireless medium is used. Radio waves, microwaves or infrared signals are
examples.
Bluetooth technology uses radio waves for short range communication between devices.
Cell phones, laptops, mouse, keyboard, tablets, headsets, cameras, etc.
Wi-Fi (Wireless Fidility) makes use of radio waves to transmit information across a network
like cell phones, televisions and radios.
Wi-MAX (Worldwide Interoperability for Microwave Access) uses radio waves to provide
high-speed wireless Internet access over very long distances (a whole city).
Satellite links use radio waves for long distance wireless communication systems.
Communication devices: NIC, Hub, Switch, Repeater, Bridge, Router, Gateway.
Network Interface Card (NIC): A device that enables a computer to connect to a network
and communicate.
Hub: A device used in a wired network to connect computers/devices of the same network.
Switch: An intelligent device that connects several computers to form a network.
Repeater: A device that regenerates incoming electrical, wireless or optical signals through a
communication medium
Bridge: A device used to split a network into different segments and interconnected.
Router: A device that can interconnect two networks of the same type using the same
protocol. It is more intelligent than bridge.
Gateway: A device that interconnects two different networks having different protocols.
Data Terminal Equipments: Modem, Multiplexer
Modem: It converts digital signals to analog signals and converts the analog signals back to
digital signals.
1
Computer Science - XI

Multiplexer: It combines (multiplexes) the inputs from different sources and sends them
through different channels of a medium.
Topology: The way in which the nodes are physically interconnected to form a network.
Major topologies are bus, star, ring and mesh.

Bus Topology Star Topology Ring Topology

Types of network: PAN (Personal Area Network), LAN (Local Area Network), MAN
(Metropolitan Area Network) and WAN (Wide Area Network).

Logical Classification: Peer-to-peer and Client server


Peer-to-peer network: No dedicated servers. Here a number of computers are connected
together for the purpose of sharing information or devices.
Client-server: It consists of high-end computer (called server) serving lower configuration
machines called clients.
Protocol: The set of rules to be followed in a network for data transmission. TCP/IP, SPx/IPx
are examples. HTTP, FTP and DNS are three sub protocols of TCP/IP protocol suite.
HTTP stands for Hypertext Transfer Protocol. It is a standard protocol for transferring
requests from client-side and to receive responses from the server-side.
FTP stands for File Transfer Protocol. It is a standard for exchanging of data and program
files across a network.
DNS stands for Domain Name System. DNS returns the IP address of the domain name, that
we type in our web browser’s address bar.
Media Access Control (MAC) address: A universally unique address (12 digit hexadecimal
number) assigned to each NIC (Network Interface Card) by its manufacturer.
IP address: A unique 4 part numeric address assigned to each node on a network, for their
unique identification.
URL stands for Uniform Resource Locator. URL is a formatted text string used by web
browsers to identify a network resource on the Internet. URL string can be divided into
three parts – Network protocol, Domain name, File name.

2
Computer Science - XI
Questions from Previous Years’ Question Papers

1. Which one of the following transmission media carries information in the form of light
signals?
a) Coaxial cable b) Shielded twisted pair
c) Optical fibre cable d) Wi-Fi (1) (July 2017)
2. Internet is an example of .
a) MAN b) PAN c) WAN d) LAN (1) (July 2017)
3. Explain the advantages of forming networked computers than keeping them stand-
alone computers. (3) (July 2017)
4. a) Different networks with different protocols are connected by a device called …………
(i) Router (ii) Bridge (iii) Switch (iv) Gateway (1) (March 2017)
b) Define protocol. (1) (March 2017)
5. Compare any three types of networks based on span of geographical area.
(3) (March 2017)
6. Write notes on the following:
a) IP address b) MAC address c) Modem (3) (Sept. 2016)
7. Define network topology. Explain any four network topologies in detail.
(3) (Sept. 2016)
8. Identify the type of LAN topology in which there are more than one path between
nodes.
(a) Star (b) Ring (c) Mesh (d) Bus (1) (March 2016)
9. Any device which is directly connected to a network is generally known as .
(1) (March 2015)
10. In ……… topology all the nodes are connected to a main cable. (1) (Sept. 2015)
11. Bluetooth can be used for ……………….. communication.
i) long distance ii) short distance
iii) mobile phone iv) all of these (1) (Sept. 2015)
12. ABC Ltd. required connecting their computers in their company without using wires.
Suggest suitable medium to connect the computers. Explain. (3) (Sept. 2015)
13. (a) To make data transfer faster, a switch stores two different addresses of all the
devices connected to it. What are they? (1)
(b) There are 5 computers in your computer lab. Write short notes on any three
possible methods to interconnect these computers. Draw the diagram of each method.
(3) (March 2015)

3
Computer Science - XI

Chapter 12 – Internet and Mobile Computing

Internet is an interconnected system of computer networks that serves the users all over the
world. Vinton Gray Cerf is considered as the father of Internet. Tim Berners Lee proposed the
idea of World Wide Web (WWW).
Intranet is considered as a private computer network similar to Internet that uses TCP/IP
protocol to share information, software or services within an organisation.

Hardware and software requirements for connecting to the Internet: (i) A computer with
Network Interface Card (wired/wireless) facility and an operating system that supports TCP/IP
protocol (ii) Modem (iii) An Internet account given by an Internet Service Provider (ISP) (iv)
Software like browser, client application for e-mail, chat, etc.

Dial-up connectivity Vs Wired broadband connectivity:

Popular broadband technologies: Integrated Services Digital Network (ISDN), Cable Internet,
Digital Subscriber Line (DSL), Leased Lines and Fiber to the Home (FTTH).

ISDN: It is a broadband service capable of transporting voice and digital data.

Cable Internet: Internet access is provided using coaxial cables laid for television signal
transmission to our homes.

DSL: It is another broadband service that provides connection to the Internet through standard
telephone lines.

Leased lines: These are dedicated lines used to provide Internet facility to ISPs, business, and
other large enterprises.

Fibre to the Home (FTTH): It uses optical fibres for data transmission. Optical fibres are laid
from the ISP to our homes. FTTH technology has been accepted worldwide to implement high
speed Internet to the home.

Wireless broadband connectivity: It provides almost the same speed as that of a wired
broadband connection. The popular wireless broadband accesses are Mobile Broadband, Wi-
MAX, Satellite Broadband and Wi-Fi.

Mobile broadband: It is wireless Internet access using mobile phone, USB wireless modem,
tablet or other mobile devices. The modem is built into mobile phones, tablets, USB dongles,
etc.

1
Computer Science - XI
Wi-MAX: Worldwide Interoperability for Microwave Access (Wi-MAX) offers a Metropolitan
Area Network which can provide wireless Internet up to a distance of 50 Km.

Satellite broadband technology: It is a method by which Internet connectivity is provided


through a satellite.

Sharing an Internet connection: Internet connection can be shared among several computers
using a LAN, Wi-Fi network or Li-Fi network.
Services on the Internet: Services like WWW, e-mail, search engines, social media, etc. are
widely used throughout the globe.

World Wide Web (WWW): It is a system of interlinked hypertext documents accessed via the
Internet. It is a huge client-server system consisting of millions of clients and servers connected
together. Each server maintains a collection of documents and they can be accessed using a
reference called Uniform Resource Locator (URL).

Web browser: It is a software use to retrieve or present information and to navigate through
web pages in the World Wide Web. Eg: Google Chrome, Internet Explorer, Mozilla Firefox,
Opera, and Safari.

Web browsing procedure:

Search engines: Internet search engine websites are special programs that are designed to help
people to find information available in World Wide Web. Search engine web sites use programs
called web crawlers or spiders or robots to search the web.

Working of Search engines: Web crawlers search the web pages stored in the different web
servers and find possible keywords. These keywords are stored along with their URLs to form
an index in the search engine’s web servers. When a particular topic (keyword), is searched, the
web crawler searches the index, and select a list of URLs where the particular topic is found and
displays the list as the result.

Electronic mail or e-mail: It is a method of exchanging digital messages between computers


over Internet.

2
Computer Science - XI
Sections of e-mail: To (Recipient Address), Cc (Carbon copy to the secondary recipients), Bcc
(Blind carbon copy to the tertiary recipients), Subject, Content, Attachments.

Working of e-mail:

Advantages of e-mail: Speed, easy to use, provision of attachments, environment friendly, easy
reply to an e-mail, cost-effective, available anywhere anytime.

Types of social media: Internet forums, social blogs, micro blogs, wikis, social networks,
content communities and a lot more.

Internet forums: It is an online discussion website where people can engage in conversations in
the form of posted messages. Eg: Ubuntu Forum

Social blogs: It is a discussion or informational website consisting of entries or posts displayed


in the reverse chronological order i.e., the most recent post appears first. Eg: Blogger.com,
Wordpress.com.

Microblogs: They allow users to exchange short sentences, individual images or video links. It
offers a communication mode that is spontaneous and can influence public opinion.
Twitter.com is a popular micro blogging site.

Wikis: Wikis allow people to add content or edit existing information in a web page, to form a
community document. Wiki is a type of content management system. Eg: wikipedia.org.

Social networks: These sites allow people to build personal web pages and then connect with
friends to communicate and share content. We can share text, pictures, videos, etc. and
comment to the posts. Eg: facebook.com, linkedin.com.

Content communities: These are websites that organise and share contents like photos, videos,
etc. Eg: Youtube.com, flickr.com.

3
Computer Science - XI
Advantages of social media: Bring people together, help to plan and organise events,
promoting business, enhance social skills.

Limitation of social media: Intrusion to privacy, addiction, spread rumours.

Computer virus: It is a program that attaches itself to another program or file enabling it to
spread from one computer to another without our knowledge and interferes with the normal
operation of a computer.

Computer worm: It is a stand-alone malware (malicious software) program that replicates itself
in order to spread to other computers.
Trojan horse: It will appear to be a useful software but will actually do damage once installed
or run on your computer.

Spams or junk mails: These are unsolicited e-mails sent indiscriminately to persons to promote
a product or service.

Hacking: It is a technical effort to manipulate the normal behaviour of network connections


and connected systems. Computer experts perform hacking to test the security and find the
vulnerabilities in computer networks and computer systems. Such computer experts are often
called ‘white hats’ and such hacking is called ethical hacking. Computer criminals break into
secure networks to destroy data or make the network unusable for those who are authorised
to use the network. Such criminals are called ‘black hats’. There are ‘grey hat hackers’, who
sometimes act illegally, though with good intentions, to identify the vulnerabilities.

Denial of Service (DoS): It is a network attack is usually aimed at a web server. Such an attack
forces the server/computer to restart.

Phishing: It is an attempt to acquire information such as usernames, passwords and credit card
details by posing as the original website, mostly that of banks and other financial institutions.
Phishing websites have URLs and home pages similar to their original ones. The act of creating
such a misleading website is called spoofing.

Man-in-the-middle attack: It refers to an attack in which an attacker secretly intercepts


electronic messages between the sender and the receiver and then captures, inserts and
modifies messages during message transmission. Encrypted connections such as HTTPS (HTTP
Secure), SFTP (Secure FTP) etc. should be used for secure transactions, so that intruders cannot
modify the messages.

Firewall: It is a system of computer hardware and software that provides security to the
computer network in an organisation. It denies malicious data from entering into the computer
networks.

Antivirus programs: These tools are used to detect viruses and cure the infected system. It
scans files in the computer system for known viruses and removes them if found.

4
Computer Science - XI
Cookies: These are small text files that are created when we use a browser to visit a website. It
remembers our user name, preferences, e-mail address, etc. It is always possible for a hacker
to use cookies for malicious purposes. Cookies can be used to act as a spyware.

Mobile computing: It is a technology that has computing capability and can transmit/receive
data while in motion. Mobile computing requires portable computing devices like laptops,
tablets, smart phones, etc., wireless communication networks and connectivity to Internet.

Generations of mobile communication: 1G mobile phones were based on the analog system
and provided basic voice facility only. 2G networks follow digital system for communication.
Picture messages and MMS (Multimedia Messaging Service) were introduced in 2G. 3G
networks offered multimedia services combining voice and data. It has the facility to send and
receive large amounts of data using a mobile phone. 4G system, also called Long Term
Evolution (L.T.E.), provides mobile ultra-broadband Internet access to mobile devices. 4G
networks offer very high speeds and provide good quality images and videos.

Mobile communication technologies: SMS, MMS, GPS and smart cards. Short Message Service
(SMS) is a text messaging service in mobile communication systems that allows exchanging
short text messages containing up to 160 characters. Multimedia Messaging Service (MMS) is a
standard way to send and receive messages that consists of multimedia content using mobile
phones. MMS does not specify a maximum size for a multimedia message and it supports
contents such as text, graphics, music, video clips and more. Global Positioning System (GPS) is
a satellite based navigation system that is used to locate a geographical position anywhere on
earth, using its longitude and latitude. GPS is used for vehicle fleet tracking by transporting
companies to track the movement of their trucks. A smart card is a plastic card embedded with
a computer chip / memory that stores and transacts data. The advantages of using smart cards
is that it is secure (data is protected), intelligent (it can store and process data) and that it is
convenient (it is easy to carry).
Mobile Operating System: The software that manages the hardware, multimedia functions,
Internet connectivity, etc. in a mobile device. Eg: Android from Google, iOS from Apple,
BlackBerry OS from BlackBerry and Windows Phone from Microsoft.

Android mobile OS: It is a Linux-based operating system designed mainly for touch screen
mobile devices such as smart phones and tablet computers. It was originally developed by
Android Inc. that was founded in Palo Alto, California in 2003 by Andy Rubin and his friends. In
2005, Google acquired Android Inc. making it a wholly owned subsidiary of Google.

Questions from Previous Years’ Question Papers

1. SIM card is a smart card used inside a mobile phone. What is the full form of SIM?
a) Subscriber Identity Module b) Subscriber Identity Mobile
c) Subscriber Identification Mobile d) Single Identity Mobile (1) (July 2017)
2. Which one of the following terms refers to ethical hacker?
a) Black hat b) Blue hat c) Grey hat d) White hat (1) (July 2017)
3. Explain the influence of social media in society. (3) (July 2017)

5
Computer Science - XI
4. Find the best matches from the given definitions for the terms in the given list.
(Worm, Hacking, Phishing, Spam)
a) Unsolicited emails sent indiscriminately.
b) A technical effort to manipulate the normal behavior of networked computer system.
c) A stand alone malware program usually makes the data traffic slow.
d) Attempt to acquire information like user names and passwords by posing as the
original websites.
e) Appear to be a useful software but will do damage like deleting necessary files.
(2) (March 2017)
5. Susheel’s email id is susheel@gmail.com. He sends an email to Rani whose email id is
rani@yahoo.com. How is the mail sent from Susheel’s computer to Rani’s computer?
(3) (March 2017)
6. Which one of the following technologies is used for locating geographic positions according
to satellite based navigation system?
a) MMS b) GPS c) GSM d) SMS (1) (Sept. 2016)
7. Explain DoS attack on servers. (2) (Sept. 2016)
8. What is browsing? Briefly explain the steps needed for browsing. (3) (Sept. 2016)
9. Briefly explain any three mobile communication services. (3) (March 2016)
10. Define Internet. Compare two types of Internet connectivities namely Dial-up and

Broadband. (3) (March 2016)


11. Write the full form of FTTH. (1) (March 2016)
12. Pick the odd one out from the following list:
(a) Spam (b) Trojan horse (c) Phishing (d) Firewall (1) (March 2016)
13. Which one of the following statements is TRUE in relation with Wi-MAX Internet
connectivity? (1) (March 2016)
(a) Make use of satellite connection (b) Uses cable connection
(c) Uses laser beam for connection (d) Microwave is used for connectivity
14. a) Acquiring information such as username, password, credit card details etc. using
misleading websites is known as ………… (1)
b) Pick odd one out:
Google, Safari, Mozilla Firefox, Internet explorer (1) (Sept. 2015)
15. One of your friends wants to send an email to his father abroad to convey him birthday
wishes with a painting done by him. Explain the structure and working of email to him.
(3) (Sept. 2015)
16. (a) Define Intranet. (1) (March 2015)
(b) Write the structure of an e-mail address. (1) (March 2015)
17. Social media plays an important role in today’s life. Write notes supporting and opposing
its impacts. (3) (March 2015)

You might also like