Hsslive XI - ComputerScience ShortNotes - SajanMathew Signed
Hsslive XI - ComputerScience ShortNotes - SajanMathew Signed
The mathematician John Von Neumann designed computer Number representation methods: (i) Sign and magnitude
architecture. It is known as Von Neumann architecture. It representation (ii) 1’s complement representation (iii) 2’s
consists of a central processing unit (CPU) containing complement representation.
ASCII: American Standard Code for Information 1 Nibble = 4 Bits 1 GB (Giga Byte) = 1024 MB
Interchange. 1 Byte = 8 Bits 1 TB (Tera Byte) = 1024 GB
1 KB = 1024 Bytes 1 PB (Peta Byte) = 1024 TB
EBCDIC: Extended Binary Coded Decimal Interchange
Code. This is similar to ASCII and is an 8 bit code. It can
RAM Vs ROM:
represent 256 characters.
Cache memory: It is a small and fast memory between the
ISCII: Indian Standard Code for Information Interchange
processor and RAM
or Indian Script Code for Information Interchange. It uses
8-bits and can represent various writing systems of India. Storage unit of computer: Two types – primary and
secondary.
Unicode: Unicode can represent characters in almost all
written languages of the world. i. Primary storage: It is also known as main memory. It is
again divided into two – Random Access Memory (RAM)
Boolean operations: The operations performed on the
and Read Only Memory (ROM).
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.
Universal Gates: The NAND and NOR gates are called ii. Secondary storage: It is also known as auxiliary
universal gates. A universal gate is a gate which can storage. It has huge storage capacity and the storage is
implement any Boolean function without using any other permanent - . Hard disk, CDs, DVDs, memory sticks,
gate type. Input devices: These devices feed data and instructions
NAND: It is an inverted AND operation. NAND gate is an from the user into the computer.
inverted AND gate. 1. Keyboard: Allows the user to input text data consisting
NOR: It is an inverted OR operation. NOR gate is an of alphabets, numbers and other characters.
inverted OR gate. 2. Mouse: A small handheld device used to position the
cursor or move the pointer on the computer screen
Chapter 3: Computer System Organisation 3. Light pen: A pointing device shaped like a pen. Has
the advantage of ‘drawing’ directly onto the screen.
Data processing: It refers to the operations or activities
performed on data to generate information. Data 4. Touch screen: Allows the user to operate/make
processing proceeds through six stages – selections by simply touching on the display screen.
Capturing data, Input of data, Storage of data, Processing / 5. Graphic tablet: Consists of an electronic writing area
manipulating data, Output of information, and Distribution and a special ‘pen’ that works with it. Allows artists to
of information. create graphical images with actions similar to
traditional drawing tools.
Functional Units of a computer: Input Unit, Central
Processing Unit (CPU), Storage Unit and Output Unit. 6. Joystick: Used to play video games, control training
simulators and robots.
Computer: An electronic machine designed to accept the
data and instructions, performs arithmetic and logical 7. Microphone: Accepts sound in analogue nature as
operations on the data according to a set of instructions and input and converts it to digital format.
output the results or information. 8. Scanner: Allows capturing of information, like pictures
Characteristics of computer: Speed, accuracy, diligence, or text and converting it into a digital format that can be
versatility, huge memory, no IQ, lack of decision making. edited using a computer.
Important registers inside a CPU: 9. OMR: Scanning device that reads predefined positions
and records where marks are made on the printed form.
i. Accumulator:, ii. Memory Address Register (MAR): , iii. Useful for applications such as objective type tests and
Memory Buffer Register (MBR):, iv. Instruction Register questionnaires.
(IR):, v. Program Counter (PC
10. Bar Code Reader: A bar code is a set of vertical lines
Measuring units of memory: of different thicknesses and spacing that represent a
Binary Digit = 1 Bit 1 MB (Mega Byte) = 1024 KB
number. Barcode readers are used to input data from System software: A set of programs which aids in the
such set of barcodes. execution of a general user’s computational requirements
on a computer system.
11. QR (Quick Response) code is similar to barcodes.
Barcodes are single dimensional where as QR codes are The components of system softwareare Operating system,
two dimensional. Language processors and Utility software.
12. Biometric sensor: Identifies unique human physical Operating system (OS): A set of programs that acts as an
features like fingerprints, retina, iris patterns, etc. to interface between the user and computer hardware.
identify, verify and authenticate the identity of the user.
Function of OS: Process management, memory
13. Smart card reader: These are used to access data in a management, file management, device management,
smart card. Smart card is a plastic card that stores and security management and command interpretation.
transacts data. Used in banking, healthcare, telephone
Computer languages: Machine language, assembly
calling, electronic cash payments and other
language and High Level Languages
applications.
Language processors: These are the system programs that
14. Digital camera: Takes pictures and videos and
translate programs written in high level language or
converts it to the digital format. Web camera is a
assembly language into its equivalent machine language.
compact and less expensive version of a digital camera.
Types of language processors:
Output devices: These devices present information from a
computer system to the user. 1. Assembler (translates the program code written
in assembly language to machine language), 2. Interpreter
1. Monitor: Display devices include CRT monitors, LCD
(converts a HLL program into machine language line by
monitors, TFT monitors, LED monitors, gas plasma
line) and 3. Compiler (translates a program written in high
monitors, Organic Light Emitting Diode (OLED)
level language into machine language).
Monitors, etc.
Utility software:
2. LCD projector: An LCD projector is a type of video
projector for displaying video, images or computer data 1. Compression utility: Large files can be compressed so
on a large screen or other flat surface. that they take less storage area.
3. Printer: Used to produce hardcopy output. The output 2. Disk defragmenter: A program that rearranges files on
printed on paper is known as hardcopy. Classified as a computer hard disk.
Impact or Non-impact printers. 3. Backup utility: These programs facilitate the backing
Dot-matrix uses impact mechanism. It can print up of disk.
carbon copies with less printing cost. These printers 4. Antivirus programs: A utility program that scans the
are slow and noisy. computer system for viruses.
Inkjet printers, Laser printers and thermal printers General purpose software: These are used to perform
are non-impact printers tasks in a particular application area.
4. Plotter: A plotter is an output device used to produce 1. Word processing software: It is designed for creating
hardcopies of graphs and designs on the paper. and modifying documents. Eg: MS Word, Open Office
5. 3D printer: A 3D printer is an output device used to Writer, Apple iWork Pages, etc.
print 3D objects. It can produce different kinds of 2. Spreadsheet software: This software allows users to
objects, in different materials, using the same printer. perform calculations. Eg: Microsoft Excel, Open Office
e-Waste: Electronic waste may be defined as discarded Calc, Lotus 1-2-3 and Apple iWork Numbers.
computers, office electronic equipment, entertainment 3. Presentation software: The software is used to display
devices, mobile phones, television sets and refrigerators. information in the form of a slide show. Eg: Microsoft
e-Waste disposal methods: Re-use, incineration PowerPoint, Apple iWork Keynote and Open Office Impress.
(combustion process in which the waste is burned in 4. Database software: Database is an organised collection
incinerators at a high temperature), recycling, (the process of data arranged in tabular form. Eg: Microsoft Access,
of making new products from a product that has originally Oracle, Postgres SQL, My SQL, etc.
served its purpose) and land filling.
5. Multimedia software: Multimedia is the integration of
Software: A general term used to denote a set of programs multiple forms of media. Eg: VLC Player, Adobe
that help us to use the computer system. Two types - Flash, Real Player, Media Player, etc.
system software, application software.
The Free Software Foundation (FSF) defines the four
freedoms for free and open source software:
Freedom 0 : The freedom to run program.
Freedom 1 : The freedom to study
Freedom 2 : The freedom to distribute copies
Chapter 5: Introduction to C++ Programming
Freedom 3 : The freedom to improve the program
Character set: The fundamental unit of C++ language.
The character set of C++ is categorized as (i) Letters (A –
Chapter 4 – Principles of Programming and
Z, a – z), (ii) Digits (0 – 9), (iii) Special characters
Problem Solving (iv)White spaces.
Computer program: A sequence of instructions given to a
Tokens: The fundamental building blocks of the program.
computer to solve a problem.
C++ has five types of tokens – Keywords, Identifiers,
Program instruction: It is an action oriented statement Literals, Punctuators and Operators.
and it tells the computer what operation it should perform. Keywords: The words (tokens) that convey a specific
meaning to the language compiler. These are also known
Top down design: It is the process of solving a complex
as reserved words.
problem by breaking it down into different tasks and
Identifiers: These are the user-defined words used to name
solving each task from main to sub.
different program elements such as memory locations,
Bottom up design: It is the process of breaking a complex statements, functions, objects, classes etc. The identifiers
problem into smaller sub tasks and solving each task from of
sub to main. memory locations are called variables.
Stages of problem solving: Rules for naming identifiers: An arbitrary long sequence
of letters, digits and underscores.
(i) Problem identification The first character must be a letter or underscore ( _ ).
(ii) Preparing algorithms and flowcharts White space and special characters are not allowed.
(iii) Coding the program using programming language Keywords cannot be used. Upper and lower case letters are
(iv) Translation treated
(v) Debugging differently.
(vi)Execution and Testing and Literals: Data items that never change their value during
(vii) Documentation the program run. They are often referred to as constants.
Literals are of four types – Integer literals, Floating
Algorithm: It is a step-by-step procedure to solve a point literals, Character literals(‘) and String literals.(“)
problem, where each step represents a specific task to be Escape sequences: These special character constants that
carried out. represent non-graphic symbols. It consists of a backslash
Flowchart: The pictorial representation of an algorithm (\) followed by one or more specific characters.
with specific symbols for instructions and arrows showing .
the sequence of operations. Chapter 6: Data Types and Operators
Input / Process
Flowchart Symbols: Start/Stop Output Data types: These are the means to identify the nature of
Decisi
Flow line
the data and the set of operations that can be performed on
on the data.
Advantages of flowcharts: Better communication,
Effective analysis, Effective synthesis, Efficient coding. Fundamental data types: The five fundamental data types
in C++ are char (1byte), int (4byte), float (4byte), double
Translation: It is the process of converting a program (8byte) and void (0byte).
written in high level language into its equivalent version in
machine language. Data type modifiers: The keywords used to alter the size,
range or precision of data supported by the basic data
Debugging: It is the process of detecting and correcting types. Important modifiers are signed, unsigned, long and
the errors in a program. short.
Syntax errors: The errors occur when the rules or syntax Variables: The names given to memory locations.
of the programming language are not followed.
Operators: The tokens or symbols that trigger computer to
Logical error: It is due to improper planning of the carry out operations. The data on which an operation are
program's logic and revealed during the execution of the called operands. An operand may be either a constant or a
program. variable. Classified into three –unary, binary and ternary.
Run time error: These errors occur unexpectedly when Arithmetic operators: Used to perform basic arithmetic
computer becomes unable to process some improper data. operations.
Documentation: 1. Internal documentation is done Modulus operator (%): Also called as mod operator. It
through comments in programs. 2. Various manuals gives the remainder value during arithmetic division.
provide external documentation.
Relational operators: Used for comparing numeric data. if (test expression 1)
These are binary operators. The result of any relational statement block 1;
operation will be either True or False. else if (test expression 2)
statement block 2;
Expression: Composed of operators and operands.
Classified into arithmetic expressions, relational switch statement
expressions and logical expressions.
This selection statement successively tests the value of a
Type conversion: Conversion of the data type of an variable or an expression against a list of integers or
operand into another type. Done in two ways: implicitly character constants.
and explicitly.
switch(expression)
Type promotion: It is the implicit type conversion is {case constant_1 : statement block 1;
performed by C++ compiler internally. break;
case constant_2 : statement block 2;
Type casting: It is the explicit type conversion and is done
break;
by the programmer by specifying the data type within
default : statement block n;}
parentheses to the left of the operand.
Variable declaration: data_type <variable1>,<variable2>;
Variable initialisation: Supplying value to a variable at
the time of its declaration.
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
using namespace statement: It tells the compiler about a
namespace where it should search for the elements used in The conditional operator (?:)
the program.
C++ has a ternary operator. It is the conditional operator
main() function: An essential function in every C++ (?:) consisting of the symbols ? and : (a question mark and
program. The execution starts at main() and ends within a colon). It requires three operands.
main().
Looping (Iteration) Statements
Four elements of a loop:
Chapter 7: Control Statements 1. Initialisation: The loop control variable (Variable
Decision making statements or Selection statements. if used in the condition) gets its first value..
and switch are the two types of selection statements in 2. Test expression: It is a relational or logical
C++. The selection will be based on conditions. expression whose value is either True or False.
if statement 3. Update statement: The update statement modifies
The if statement is used to select a set of statements for the loop control variable by changing its value..
execution based on a condition. 4. Body of the loop: The statements that need to be
if – else statement executed repeatedly constitute the body of the loop.
The syntax is: while statement
if (test expression) It is an entry-controlled loop. The condition is checked first
statement block 1; and if it is True the body of the loop will be executed.
else for statement
statement block 2;
When we write an if statement inside another if block, it is It is also an entry-controlled loop in C++. All the three
called nesting. loop elements (initialisation, test expression and update
statement) are placed together in for statement.
The else if ladder
do...while statement
When we want to select one action from more than two
actions, different conditions will be given and each It is also an exit-controlled loop. The body of the loop will
condition will decide which statement is to be selected for execute at least once.
execution.
Nesting of a loop: Placing a loop inside the body of A string can be input using the statement:
another loop. When we nest two loops, the outer loop
cin >> my_name;
counts the number of completed repetitions of the inner
loop. 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() function.
There are functions to perform input output operation:
Type of Console Stream Operation
data (stdio.h) (iostream.h)
Character getchar() cin.get() Character input
Chapter 8: Arrays functions putchar() cout.put() Character output
String gets() cin.getline() String input
An array is a collection of elements of the same type
Functions puts() out.write() String output
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 Chapter 10: Functions
subscript.
The process of breaking large programs into smaller sub
Syntax: data_type array_name[size]; programs is called modularisation. The sub programs
Eg: int num[10]; are generally called functions.
int score[5] = {98, 87, 92, 79, 85}; Merits of modular programming
• Reduces the size of the program.
total_bytes = sizeof(array_type) × size_of_array
• Less chance of error occurrence.
Array Operations: • Reduces programming complexity.
1. Traversal • Improves reusability.
2. Searching Function is a named unit of statements in a program to
a. Linear Serach b. Binary Search perform a specific task as part of the solution.
3. Sorting
Predefined functions
a. Selection Sort b. Bubble Sort
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
Two dimensional (2D) arrays performing the task. This result is known as value
A two dimensional array is an array in which each element returned by the function. Some functions do not return
itself is an array. For instance, an array AR[m][n] is a 2D any value; rather they perform the specified task.
array containing m rows and n columns.
data_type array_name[rows][columns];
The indices (subscripts) of rows and columns, start at 0 and
ends at (rows–1) and (columns–1) respectively.
int marks[5][4];
strcmp() strcmp(string1,
string2) • 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.
abs() To find the absolute value of an integer.
Mathematical
abs(int)
Functions
(math.h)
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
Character Functions (ctype.h)
itoa() itoa(int n, char c[], This function is used to convert an integer value to string type. It
requires three arguments. The first one is the number to be
Conversion
int len)
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() setw(int size) This function is used to set the width for the subsequent string.
The word hello will be displayed right aligned within a span of 10
Function (iomanip.h)
I/O Manipulating