11 CS Guide 2022 2023
11 CS Guide 2022 2023
11 CS Guide 2022 2023
11
Computer
Science GUIDE
ELANGOVAN
2
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
Primarymemory
3
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
15. Define control unit or It is used for computer securityinstead of using passwords.
Write the functions of control unit. It is a biometric technique.
It is a very safe and convenient.
It controls the entire operation of a computerthrough signals. Track Ball:
In Track ball user spins the ball in various directions to navigate the
16. What is the function of memory? screen movements.
Retinal Scanner:
Memory unit It performs a retinalscan.
It is used to storedata and instructions. It is a biometric technique .
There are two types of memory, they are primary memory and Light Pen:
secondary memory A light pen is a pointing device .
Primarymemory It is connected to a monitor.
It is also called main memory. The tip of the light pen contains a light-sensitiveelement
It is volatile. It detects the light from the screen enabling the computer to
Temporary memory. identify the location of the pen on the screen.
Ex. RAM Optical Character Reader:
Secondary memory It is used to detect charactersprinted or written on a paper.
It is non volatile The Scanned document can be edited using a word processor.
Permanent memory. 19.DefineBar Code
Ex. Hard Disk, CD-ROM A Bar code is a pattern printed in lines of differentthickness.
The Bar code readerscans the information on the bar codes
17. Distinguish between Primaryand secondary memory. transmits to the Computer for further processing.
20.Define QR Code Reader: QR (Quick response) Code:
Primarymemory The QR code is the 2D bar code which can be read by a camera .
It is also called main memory. Define Voice Input Systems:
It is volatile. Microphone serves as a voice Input device.
Temporary memory. It captures the voice data and send it to the Computer.
Ex. RAM Define Digital Camera:
Secondary memory It captures images / videos directly in the digital form.
It is non volatile It uses a CCD (Charge Coupled Device) electronic chip.
Permanent memory. It converts light rays into digital format.
Ex. Hard Disk, CD-ROM Touch Screen:
A touch screen is a display device that allows the user to
18.Explain Some Important Input Devices. interact with a computer by using the finger.
Touch screens are used in computers, laptops, monitors, smart
Keyboard: phones, tablets, ATM etc..
Keyboard is the most common inputdevice.
It is used to give data and instructions to computer by typing on 21.Explain Some Output Devices.
the keyboard.
The keys for letters, numbers and special characters are known Monitor:
as a character keys Monitor is the most commonly used output device to display the
Function keys are used to perform different functions. information.
Other keysare enter and editing keys, function keys, navigation Pictures are formed with picture elements called PIXELS.
keys, numeric keypad and lock keys etc.. It can be MonochromeorColour
Mouse: CRT (Cathode Ray Tube),
It is an input device LCD (Liquid Crystal Display) and
Mouse is a pointing device . LED (Light Emitting Diodes) are the types of monitor.
It can be used to select icons, menus, commandbuttonsetc Monitor works with the VGA (Video Graphics Array) card.
Some mouse actions are i) move, ii)click, iii)double click, VGA acts as an interface between the computer and monitor.
iv)right click, v)drag and drop. Plotter:
Scanner: Plotter is used to produce graphical output on papers.
It converts printed or writtenInformation into a digital It uses single color or multi color pens to draw pictures.
format(file) into computer‟s memory.
4
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
Printers are used to print the information on papers. It spraysionised ink at a sheet of paper.
They are two main categories: It can spread millions of dots of ink at the paper every single
• Impact Printers • Non Impact printers second
.
Laser Printers It has colour cartridges which combined Magenta, Yellow and Cyan
It works similar to photocopiers inks.
It makes a laser beam scan back and front across a drum A black cartridge is used for monochrome output.
inside the printer, make up a pattern.
It can produce very good quality of graphic images. 21.Explain Booting of computer
Inkjet Printers: When a computer is switched on, there is no information in its RAM.
Inkjet printers work by spraying ionised ink at a sheet of paper. In ROM, the pre-written program called POST (Power on Self
An Inkjet printer can spread millions of dots of ink at the paper Test) will be executed first.
every single second. This program checks if the devices like RAM, keyboard, etc., are
It hascolour cartridges which combined Magenta, Yellow and Cyan connected properly and ready to operate.
inks. Then the BIOS (Basic Input Output System) gets executed.
A black cartridge is used for monochrome output. This process is called Booting.
Speakers: Thereafter, a program called “Bootstrap Loader” transfers OS from
Speakers produce voice output (audio) . hard disk into main memory(RAM).
This has become very common in places like airlines, schools, Now the OS gets loaded (Windows/Linux, etc.,) and will get
banks, railway stations, etc.. executed.
Booting process is of two types.
22.Differentiate between Impact and Non Impact printers. 1)Cold Booting 2) Warm Booting
Cold (Hard)Booting:
computer starts from initial state
Impact Printers Non-Impact Printers Booting process initiate by pressing Power button.
It prints with striking of do not use striking All diagnostic testscould be carried out in this process.
hammers or pins on mechanism for printing. Warm (soft)Booting:
ribbon. Does not start from initial state.
It can print by using They use electrostatic or Booting process initiate by pressing Reset button.
mechanicalpressure laser technology. All diagnostic tests need not be carried out in this process.
It makes noise . It is silent
Poor Quality and speed Good Quality and speed 22.Difference between cold and warm booting Ref above ans
Ex. Dot Matrix printers , Ex. Laser printers , Inkjet
Line matrix printers printers
6
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
7
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
8.Find 1‟s and 2‟s complement for (–135)10 12.Convert (150)10 into Binary, then convert that binary number
Ref. above answer into octal
9.We cannot find 1‟s complement for (28) 10 .
Reason: Because 28 is a positive number. 2|150
This is for negative numbers only 2|75 0
10.Binary Add a) -2210 + 1510 2|32 1
2|16 0
-22 2|8 0
2|22 2|4 0
2|11 0 2|2 0
2|5 1 2|1 0
2|2 1
2|1 0 (150)10 = (1000 0010)2
1101011
111010
------------
0110001
-------------
8
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
9
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
Note:
Fraction repeats, the product is the same as in the first step. Conversion of fractional Binary to Decimal
Write the integer parts from top to bottom. 30.Conversion of fractional Binary to Decimal equivalent
Hence (0.2) 10 =(0.00110011…) 2
Binary to Decimal Conversion
27.Convert (1 1 0 0 1)2 into its equivalent decimal number.
11001
1 X 25 + 1 X24 +0 X 23 + 0 X 22 + 1 X 20
16 + 8 + 0 + 0 + 1
25
(11001)2 = (25)10
Conversion Table
Hex Oct Dec Binary
0 0 0 0 0 0 0 31.Convert the given Binary number (11.011) 2 into its decimal
1 1 1 0 0 0 1 equivalent Integer part (11) 2 = 3
2 2 2 0 0 1 0
3 3 3 0 0 1 1
4 4 4 0 1 0 0
5 5 5 0 1 0 1
6 6 6 0 1 1 0 3 + . (0x0.5 + 1 x 0.25 + 1 x 0.125)
7 7 7 0 1 1 1 3 + . 0 + 0.25 + 0.125
8 8 1 0 0 0 3 +.375
9 9 1 0 0 1 3 . 375
Octal to Decimal Conversion:
A 1 0 1 0
32.Convert (1265) 8 to equivalent Decimal number
B 1 0 1 1
Positional 8 3 82 81 80
C 1 1 0 0
Given
D 1 1 0 1 Weight 512 64 8 1
E 1 1 1 0 Number 1 2 6 5
F 1 1 1 1 (1265) 8 = 512 ×1 + 64×2 + 8×6 +1×5
Binary to Octal Conversion = 512 + 128 + 48 + 5
28.Convert (11010110)2 into octal equivalent number (1265) 8 = (693) 10
Step 1: Group the given number into 3 bits from right to left.
011 010 110 Hexadecimal to Decimal Conversion
Note: The left most groups have less than 3 bits, so 0 is added to its left 33.Convert (25F) 16 into its equivalent Decimal number.
to make a group of 3 bits. Weight 256 16 1
Step-2: Find Octal equivalent of each group Positional
011 010 110 Notation 16 2 16 1 16 0
3 2 6 Given number = (2 5 F)16
(11010110)2 = (326)8 (25F) 16 = 2×256 + 5×16 + 15×1
= 512 + 80 +15
Binary to Hexadecimal Conversion (25F) 16 = (607) 10
29.Convert (1111010110)2 into Hexadecimal number
Step 1:Group the given number into 4bits from right to left. Hexadecimal to Binary Conversion
0011 1101 0110
Note: 0‟s are added to the left most group 34.Convert (8BC) 16 into equivalent Binary number
To make it a group of 4 bits
0011 1101 0110
3 D 6
(1111010110)2 = (3D6) 16
10
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
11
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
2.Define Logical Operation ( or )What are the basic logical operators NOT GATE
(fundamental operators)?
AND(+) , OR (.) and NOT(-)
3.Define TRUTH TABLE 9.Explain the fundamental gates with expression and truth table.
All the possible input along with all the possible output of given Ref.5,6,7
A Y=𝐴
combination of truth values is known as Truth Table.
0 1
8.Consider the following equation
4.What is Gate? What are the fundamental gates? 1 0
D = A + (𝐵 . C) Write truth table and Find the
Gate is a basic electronic circuit. output of D when inputs A=0,B=1,and C=0.
It operates on one or more input signals to produce an output A B C 𝐵 (𝐵.C) D =A + (𝐵 .C )
signal. 0 0 0 1 0 0
There are three fundamental gates namely AND, OR and NOT. 0 0 1 1 1 1
0 1 0 0 0 0
5.Explain about AND operator
0 1 1 0 0 0
The AND operator hastwo or moreinput variables and one
output. 1 0 0 1 0 1
The output is TRUE when all the Inputs are TRUE. 1 0 1 1 1 1
Algebraic expression : Y=A . B 1 1 0 0 0 1
TRUTH TABLE 1 1 1 0 0 1
A B Y=A.B Result: D=0
0 0 0 9.What are derived gates?
0 1 0 The gates which are derived from fundamental gates are called
1 0 0 derived Gate.
1 1 1 Ex. NAND ,NOR,XOR,XNOR etc…..
AND GATE
10.Why the NAND and NOR gates are called universal gate?
NAND and NOR gates are called Universalgates, because the
fundamental logic gates can be realized through them
11.Explain NOR Operator with an example.
6.Explain about OR operator
The NOR is the combination of NOT and OR
The OR operator has two or more input variables and one output .
NOR=inverting the output of an ORoperator.
The output is TRUE if at least one input is TRUE.
Algebraic expression : Y= 𝑨 + 𝑩
Algebraic expression : Y = A + B
TRUTH TABLE
TRUTH TABLE
A B A+B Y=𝐴+𝐵
A B Y=A+B
0 0 0 1
0 0 0
0 1 1 0
0 1 1
1 0 1 0
1 0 1
1 1 1 0
1 1 1
LOGIC CIRCUIT
OR GATE
LOGIC SYMBOL
12
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
TRUTH TABLE
12.Explain Bubbled AND Gate
A B 𝐴 𝐵 Y=𝐴 +𝐵
0 0 1 1 1
0 1 1 0 1
1 0 0 1 1
1 1 0 0 0
NOR = BUBBLED AND
They are identical. NAND = BUBBLED OR
So the circuits are interchangeable They are identical.
TRUTH TABLE So the circuits are interchangeable.
A B „A „B Y= 𝑨 .𝑩
Algebraic expression : 𝑨. 𝑩 = 𝑨 + 𝑩
0 0 1 1 1
De Morgan's Second theorem – Proved.
0 1 1 0 0
1 0 0 1 0
16.De Morgan's Second theorem – Prove. Ref.14 & 15
1 1 0 0 0
17. How AND and OR can be realized using NAND and NOR gate. (Ref.
Algebraic expression : 𝑨 + 𝑩 = 𝑨 . 𝑩 11,12 & 14 , 15)
De Morgan's First theorem – Proved
13.Prove – De Morgan First theoremRef. 11 & 12 18.Explain XOR Gate withTruth Table.
It is called exclusive - OR gate
14.Explain NAND operator with Truth Table.(or) The output is TRUE if the inputs are different,
Write short note on NAND gate: otherwiseFALSE.
The NAND is the combination of NOT and AND
NAND=inverting the output of an AND operator
Algebraic expression :Y = 𝐴. 𝐵
TRUTH TABLE
A B A.B Y = 𝐴. 𝐵
0 0 0 1
0 1 0 1
Algebraic expression : C = 𝑨 .B + A . 𝑩
1 0 0 1
TRUTH TABLE
1 1 1 0
A B 𝐴 𝐵 𝐴 .B A.𝐵 𝐴 .B+A.𝐵
All inputs are TRUE , output is FALSE
0 0 1 1 0 0 0
LOGIC CIRCUIT
0 1 1 0 1 0 1
1 0 0 1 0 1 1
1 1 0 0 0 0 0
LOGIC SYMBOL ⊕or "encircled plus"stands for the XOR
Therefore
C = A ⊕B
Logic Symbol
15.Explain Bubbled OR Gate 19.Write short note on XNOR Gate with Truth Table
Algebraic expression : C= 𝑨 + 𝑩 It is also called exclusive - NOR gate
LOGIC CIRCUIT
It is a combination XOR gate followed by NOT.
The output is FALSE if the inputs are different,
Otherwise TRUE .
20.Prove the following Absorption law by using Truth Table A + (A . 24.Explain the Derived gates with expression and truth table.
B) = A Ref. 9,11,14,15,& 16
14
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
1.Differentiate between computer architecture and Computer 5. What are the parameters which influence the characteristics of a
organization microprocessor? Or
Computer Architecture What are the Characteristics of Microprocessors.?Explain
It deals with the engineering considerations. There are three important Characteristics of Microprocessors. They are,
It is used in designing a computer. a) Clock speed
Computer Organization b) Instruction set
It deals with the hardware components. c) Word size
It is used forProgrammer.
Clock speed
2.What is microprocessor? Define microprocessor. Every microprocessor has an internal clock.
The microprocessor is a programmable multipurpose silicon chip. The speed of instruction execution in microprocessor is called the
It is controlled by clock pulses. clock speed.
It accepts input as a binary data and after processing, it Clock speed is measured in MHz (Mega Hertz) or in GHz (Giga
provides the output data as per theinstructions stored in the Hertz).
memory. Instruction set
Instruction is a commandused to perform an operationbased on
data.
Basic setof instructions to execute by microprocessor is called
an instruction set.
Types of operations
Data transfer
Arithmetic operations
3.What are the main units of Microprocessor(CPU)? Explain Logical operations
Microprocessor is made up of 3 main units. They are, Control flow
1. Arithmetic and Logic unit (ALU) Input/output
2. Control unit Word size
3. Registers (Internal Memory) The number of bits that can be processed by a processor in a
Arithmetic and Logic unit (ALU): single instruction is called its word size.
The ALU performs arithmetic operations and logical
instructions based on computer instructions 6.What is an Instruction?
Send the result to internal memory. Instruction is a commandused to perform an operationbased on
Control unit: data.
To control the overalloperations of the computer through
signals. 7.How to determine architecture of themicroprocessor?
Registers (Internal Memory): Total number of input and output pins determine the architecture of
They are used to hold the instructionand data for the execution the microprocessor
of the processor.
8.What is the use of program counter? Or What is a Program
counter?
4.What is System Bus? The Program Counter (PC) is a special register in the CPU which
A bus is a collection of wires used forcommunication between the always keeps the address of the next instruction to be executed.
Microprocessor and otherdevices.
There are 3 types of buses, they are
1. Address bus
2. Data bus
3. Control bus
15
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
9.Explain how Data communication between CPU and memory. Or Random access,
How the read and write operations are performed by a processor? Any byte of memory can be accessed directlywithoutorderly
Explain manner from starting to end.
19.Differentiate between RAM and ROM
The Central Processing Unit(CPU)has a Memory Data Register (MDR) 20.Write short note on Read Only Memory (ROM).
anda Memory Address Register (MAR). 21.Write short note on Random Access Memory (RAM).
MDR keeps the data. RAM
MAR keeps the address of data. It is volatile memory
The program counter(PC) is a special register in the CPU. It is Operating System,Application Programs and the data in
currentuse are kept temporarily
used to keep the address of the next instruction.
It allows both read and write
The Data bus is connected with MDR. Stores temporarily
The address bus is connected with MAR. When the power is turned off, whatever data stored in RAM is
The word in the RAM has the same size as MDR. lost
The read operation transfers the data from word(RAM) to MDR. They are two types SRAM,DRAM
The write operation transfers the data from MDR to Word(RAM) ROM
It is non-volatile memory
ROM stores critical programs during the manufacturing .
It can only be read.
Stores permanently
It retainsits contents even when the computer is turned off.
They are PROM,EPROM,EEPROM
16
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
23 Differentiate between EEPROM and PROM . ref.above ans 32.Explain different types of Ports and Interfaces in computer.
Differentiate between EEPROM and EPROM . ref.above ans Serial Port: To connect the external devices like screen
Which source is used to erase the content of a EPROM.ref.aboveans Parallel Port: To connect the printers.
24.Define Cache Memory. USB Ports:
It is a very high speed and expensive memory To connect external devices like cameras, scanners, mobile
It is closer to CPU. phones, external hard disks and printers to the computer.
It is in between the CPU and the main memory. It stands for Universal Serial Bus (USB)
25.Define Access Time. USB 3.0, USB 3.1 ,USB 3.2 can transfer data up to 5GB/Sec.
How quickly the memory can respond to a read / write request is VGA Connector: To connect a monitor,LCD projector.
called as Access Time. Audio Plugs: To connect sound speakers, microphone and headphones.
26.List some secondary storage Devices. PS/2 Port: To connect mouse and keyboard to PC.
1.Hard Disk 2.Compact Disc (CD) SCSI Port: To connect the hard disk drives and network connectors.
3.Digital Versatile Disc (DVD) 4.Flash Memory Devices. 5. Blu-Ray Disc
27.Write short note on Hard disk. 33.Define High Definition Multimedia Interface (HDMI) or What is
Hard disk is a magnetic disk used to store data. HDMI?
It has the stacked arrangement of disks accessed by a pair of It is an audio/video interface .
heads for each of the disks. It transfers the uncompressed video and audiodata from a
The hard disks come with a single or double sided disk. video controller, to computer monitor, LCD projector, digital
television etc.
28.Differentiate CD and DVD( ref. above answers) 32.Arrange the memory devices in ascending order based on the
Compact disk(CD) access time
CD is made up of polycarbonate plastic material. 1.Cache Memory.
A thin layer of aluminum or gold is applied to the surface. It is a very high speed and expensive memory
In CD, data is represented as "pits" encoded in a spiral track on top. It is closer to CPU.
The areas between pits are known as "lands". Itis in between the CPU and the main memory.
A motor within the CD player rotates the disk. 2.Main Memory
The capacity is 700MB RAM
Digital Versatile Disc (DVD) It is volatile memory
DVD is an optical disc It allows both read and write
DVDs are read with a laser. Stores temporarily
The disc can have one or two sides, and one or two layers per side; When the power is turned off, whatever data stored in RAM is
Single layer has 4.7 GB capacity, lost
Double layer has 8.5 GB capacity. They are two types SRAM,DRAM
Double-layered sides are usually gold-coloured ROM
Single-layered sides are usually silver-coloured, like a CD It is non-volatile memory
30.How will you differentiate a flash memory and an EEPROM? ROM stores critical programs during the manufacturing process
Flash memory itself i.ebooting
Flash memory is non-volatile. can only be read.
It can be electrically erased and reprogrammed. Stores permanently
It offers fast access times They are PROM,EPROM,EEPROM
They are either EEPROM or EPROM. 3.Secondary Storage Devices
Ex. Pendrives, Memory cards etc They are non-volatile in nature.
EEPROM Secondary storage devices are used to store data and programs
It is a non-volatile memory. permanently
It can be erased by an electrical charge. They are also called as Backup storage
It is slower in performance. They are Hard Disk,C, D,DVD,Flash memory ,Blue Ray Disk etc..
17
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
18
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
20
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
1.Operating system is a
A)Application Software B) Hardware C)System Software D)Component
2) Identify the usage of Operating Systems
A)Easy interaction between the human and computer
B)Controlling input & output Devices
C)Managing use of main memory
D)All the above
3) Which of the following is not a function of an Operating System?
A)Process Management B)Memory Management
C)Security management D)Complier Environment
4) Which of the following OS is a Commercially licensed Operating
system?
A)Windows B)UBUNTU C)FEDORA D)REDHAT
5) Which of the following Operating systems support Mobile Devices?
A)Windows 7 B)Linux C)BOSS D)iOS
6) File Management manages
A)Files B)Folders C)Directory systems D)All the Above
7) Interactive Operating System provides
A)Graphics User Interface (GUI) B)Data Distribution
C)Security Management D)Real Time Processing
8) An example for single task operating system is
a)Linux b)Windows c) MS-DOS d)Unix
9)The file management system used by linux is..
a)ext2 b)NTFS c)FAT d)NFT
21
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
22
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
23
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
25.How will you Rename a File? 28.Differentiate cut(Move) and copy options.
Using the FILE Menu copy Cut (move)
Select the File or Folder . It leaves the files or text from It removes the files or text
Click File→ Rename. source location and place them from source location and place
Type in the new name. in the destination location them in the destination location
Press Enter To copy, ctrl + c , Edit - To cut(move), ctrl + X,
Using the Right Mouse Button >copy Edit - >cut
Select the file or folder . 29.How to Deleting Files and Folders in Windows 7?
Right click - > Rename Select the file or folder.
Type in the new name. SelectRight- click -> Deleteor
Press Enter. Click File → Delete or press Delete key from the keyboard.
Using the Left Mouse Button The file will be deleted and moved to the Recycle bin.
Select the File or Folder. 30.How to delete a file or folder permanently in windows ?
Press F2 . To permanently delete a file or folder (i.e. to avoid hold down the
Type in the new name. SHIFT key, and press delete on the keyboard.
Press Enter. 31.Write a note onRecycle bin?
Recycle bin is a special folder to keep the files or folders
26.Explain the different methods of copy and cut(Move) Files and deleted by the user,
Folders. The user cannot access the files or folders in the Recycle bin
Method I - COPY and PASTE withoutrestoring it.
Select the file or folder To restore file or folder from the Recycle Bin
Click Edit → Copy or Ctrl + C or right click → Copy In recycle bin
Move to new location and paste it using Right click on a file or folder .
Click Edit → Paste or Edit -> Paste or Ctrl + V Or Right click Select Restore for one .
→ Paste Restore all for multiple files or folders
The file will be pasted in the new location. To delete
Method II-CUT and PASTE select Empty the Recycle Bin.
Select the file or folder 32.How to Creating Shortcuts on the Desktop
Click Edit → Cut or Ctrl + X or right click → cut Select the file or folder
Move to new location and paste it using • Right click on the file or folder.
Click Edit → Paste or Edit -> Paste or Ctrl + V Or Right click • Select Send to->Desktop (create shortcut)
→ Paste • A shortcut for the file or folder will now appear on your desktop.
The file will be pasted in the new location.
Method III – Drag and Drop 33.How to shutting down or logging off a computer n Windows.?
Click and drag the selected file and/or folder . Close your all open programs.
drop it where you want to copy the file and/or folder. Click start → log off or Start → Shutdown .
Your file(s) or folder(s) will now appear in the new area. • Switch User: Switch to another user account on the computer
27.How to Copying Files and Folders to removable disk? without closing your open programs and Windows processes.
Method - I • Log Off: Switch to another user account.
Select the file or folder • Lock: Lock the computer
Click Edit → Copy or Ctrl + C or right click → Copy • Restart: Reboot the computer.
Click Start→Computer. • Sleep: Puts the computer into a low-power mode that retains all
Double-click on the Removable Disk drive . running programs and open Windows for a super-quick restart.
In Removable Disk window, right-click -> Paste • Hibernate (found only on laptop computers): Puts the computer into a
Your file(s) or folder(s) will now appear in the new area. low-power mode after saving all runningprograms and open windows
METHOD II - Send To for a quick restart.
• Plug in the USB flash driveand open
• Right-click on the file you want to transfer to your removable 34.Differentiate between Hibernate and Sleep .
disk. ref. above answer
• Click Send To->Removable Disk
24
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
1.From the options given below, choose the operations managed by the
operatingsystem.
a. Memoryb. Processorc. I/O devicesd. all of the above
2. Which is the default folder for many Windows Applications to save your
file?
a. My Document b. My Pictures
c. Documents and Settings d. My Computer
3. Under which of the following OS, the option Shift + Delete –
permanently deletes afile or folder?
a.Windows 7 b.Windows 8
c.Windows10 d. None of the OS
4. What is the meaning of "Hibernate" in Windows XP/Windows 7?
a. Restart the Computer in safe mode
b. Restart the Computer in hibernate mode
c. Shutdown the Computer terminating all the running applications
d. Shutdown the Computer without closing the running applications
5.The shortcut key used to remain a file in windows
a. F2 b.F4 c.F5 d.F6
25
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
27
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
28
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
29
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
30
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
2 S1
3 else
4 if C2
5 S2
6 else
7 S3
Executes
(a) S1 (b) S2 (c) S3 (d) none
4. If C is false just before the loop, the control flows through
1 S1
2 while C
3 S2
4 S3
(a) S1 ; S3 (b) S1 ; S2 ; S3 (c)S1 ; S2 ; S2 ; S3 (d) S1 ; S2 ; S2 ; S2 ; S3
5. If C is true, S1 is executed in both the flowcharts, but S2 is
executed in
(a) (1) only (b) (2) only (c) both (1) and (2) (d) neither (1) nor (2)
6. How many times the loop is iterated?
i := 0
while i ≠ 5
i := i + 1
(a) 4 (b) 5 (c) 6 (d) 0
Answers:
1.a 2.c 3.b 4.a 5.a 6.b
31
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
32
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
11.King Vikramaditya has two magic swords. With one, he can cut off
19 heads of a dragon, but after that the dragon grows 13 heads. With CHOOSE THE CORRECT ANSWER
the other sword, he can cut off 7 heads, but 22 new heads grow. If
all heads are cut off, the dragon dies. If the dragon has originally 1.A loop invariant need not be true
1000 heads, can it ever die? (Hint:The number of heads mod 3 is (a) at the start of the loop. (b) at the start of each iteration (c) at the
invariant.) end of each iteration (d) at the start of the algorithm
2.We wish to cover a chessboard with dominoes, the number of
If the dragon has 1000 heads we start at 1000=1(mod 3) we cannot get to black squares and the number of white squares covered by
0 .so the dragon lives. dominoes, respectively, placing a domino can be modeled by
(a) b := b + 2 (b) w := w + 2 (c) b,w := b+1, w+1(d) b := w
12.Assume an 8 × 8 chessboard with the usual coloring. 3. If m x a + n x b is an invariant for the assignment a, b : = a + 8, b
"Recoloring" operation changes the color of all squares of a row or + 7, the values of m and n are
a column. You can recolor re-peatedly. The goal is to attain just one (a) m = 8, n = 7 (b) m = 7, n = -8 (c) m = 7, n = 8 (d) m = 8, n = -7
black square. Show that you cannot achieve the goal. (Hint: If a row 4. Which of the following is not an invariant of the assignment? m, n
or column has := m+2, n+3
b black squares, it changes by (|8 - b) - b|). (a) m mod 2(b) n mod 3 (c) 3 X m - 2 X n (d) 2 X m - 3 X n
5. If Fibonacci number is defined recursively as
White squares W = 32 to evaluate F(4), how many times F() is applied?
Black squares B = 32 (a) 3 (b) 4 (c) 8 (d) 9
6. Using this recursive definition
W+ B = 64 , W – B = 0 = 0 mod 4 how many multiplications are needed to calculate a10?
But the required state has 63 W 1 B (a) 11 (b) 10 (c) 9 d) 8
So W – B = 63 – 1 = 62 = 2 mod 4
Which is impossible. Answers:
1.d 2.a 3.b 4.d 5.b 6.9
13.Power can also be defined recursively as
Power (a,n)
--inputs : n integer
n
--output : a
If( n=0 ) --base case
1
else if(n is odd)
a x power (a,an-1) -- recursion step
else (n is even)
a x power (a n/2 x a n/2 ) -- recursion step
33
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
34
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
35
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
36
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
Logical Operators
Logical operators combine the results of one or more conditions. 42.Order of precedence of C++ Operators
C++ provides three logical operators.
AND(&&), OR(||) are binary operators
NOT (!) is an unary operator
Assignment Operator
It is used to assign a value to a variable.
= is commonly used as the assignment operator.
This operator copies the value at the right side to the left side
variable.
It is also a binary operator.
Syntax : Variable = Value\ constant\ expression ;
Ex. a = 10;
37
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
47.Define Input operator or define Input statement . 50.What is the use of namespace std; or Define namespace std;
The operator >> is called as “Stream extraction” or “get from” It tells the compiler to use standard namespace.
operator. Namespace collectsidentifiers used for class ,object and variables.
>> operator to get input. 51.What are the importance of main() function?
It extracts the value through the keyboard and assigns it to the Every C++ program must have a main function.
variable on its right. The main() function is the starting point where all C++ programs
The first operand is cin that identifies keyboard as the input begin their execution.
device. The executable statements should be inside the main() function.
The second operand must be a variable.
Syntax : cin>>variable; ex. cin>>a; 52.How to creating and executing a C++ program
cin>>var1>>var2>>var3; ex. cin>>a>>b;
(1) Creating Source code
Type and edit the valid C++ code .
(2) Saving source code with extension .cpp
Code should be saved with the extension .cpp
(3) Compilation
48.Define Output Operator:or output statement? Compiler links the library files with the source code and verifies
each and every line of code.
The operator<< is called the “Stream insertion” or “put to” If any mistake or error is found, it will inform you to make
operator. corrections.
<< operator to perform output operation. If there are no errors, it translates the source code into machine
It is used to send the string or the values of the variables on its readable objectfile with an extension .obj
right to the object on its left. (4) execution
The first operand is cout that identifies monitor. The object file becomes an executable file with extension .exe.
The second operand may be a constant, variable or an express An executable file, can run your application.
Syntax : cout<<variable; Ex. cout<<a;
53.What is IDE in C++?
Integrated Development Environment (IDE) makes it easy to
create, compile and execute a C++ program.
49.What is cascading of I/O operation? 54.List some Familiar C++ Compilers with IDE
The multiple use of input(>>) and output(<<) operators in a single
statement is known as cascading operators.
cin>>a>>b;
For yourself:
To display the contents of the variable:
Syntax : cout<<variable; Ex.cout<<a;
To display the Message only
Syntax : cout<<”Message”; Ex. cout<<”INDIA”;
To display the Escape Sequence only 55.Explain how to work with Dev C++?
Syntax : cout<<”\escape seq.”; Ex. cout<<”\n”; Double clickDev C++ icon to open IDE
To display the Message with Escape Sequence To create a source file,
Syntax : cout<<”Message esc.seq.”; Select File →New →Source file or Press Ctrl + N.
Ex. cout<<”INDIA\n”; After save, Click Execute → Compile and Run or press F11 key.
To display the result of expression If your program is without any error, output will appear in output
cout<<a+b; console.
To display the constant or data. 56.What are the types of Errors?
cout<<7; orcout<< 2+3; Some common types of errors are ,
To display Message escape ,sequence ,variable Syntax error
cout<<”Message”<<‟\n‟<<variable; Syntax error occur when grammatical rules of C++ are violated.
ex. cout<< “ The Result is..”<< „\t‟ << c; Ex. cout<<”INDIA” - it will throw an error because It does not end
with a semicolon.
38
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
It may be happened by wrong use of variable / operator /order of (a) Rick Mascitti (b) Rick Bjarne(c) Bill Gates (d) Dennis Ritchie
execution etc.
4. The smallest individual unit in a program is:
Here program is grammatically correct but it contains some
logical error. (a) Program (b) Algorithm(c) Flowchart (d) Tokens
Run time error.
5.Which of the following operator is extraction operator of C++? (a) >>
A run time error occurs during the execution of a program.
It occurs because of some illegal operation that takes place. (b) << (c) <> (d) ^^
6. Which of the following statements is not true?
What is the difference between “Run time error” and “Syntax
error”? Ref. above answer (a) Keywords are the reserved words convey specific meaning to the C++
What are the differences between “Logical error” and “Syntax compiler.
error”? ref.above answer
(b) Reserved words or keywords can be used as an identifier name.
(c) An integer constant must have at least one digit without a decimal
Evaluate Yourself….
point.
1. Match the following (d) Exponent form of real constants consists of two parts
A B
(a) Modulus (1) Tokens(d) 7. Which of the following is a valid string literal?
(b) Separators (2) Remainder of a division(a) (a) „A‟ (b) „Welcome‟ (c) 1232 (d) “1232”
(c) Stream extraction (3) Punctuators(b)
(d) Lexical Units (4) get from(c) 8. A program written in high level language is called as
2. Is C++ case sensitive? What is meant by the term “case (a) Object code (b) Source code (c) Executable code (d) All 9.
sensitive”?
C++ is case sensitive as it treats upper and lower- case 9.Assume a=5, b=6; what will be result of a&b?
characters differently. (a) 4 (b) 5 (c) 1 (d) 0
3. Differentiate “=” and “==”. 10. Which of the following is called as compile time operators?
= (a) sizeof (b) pointer (c) virtual (d) this
1.It is an assignment operator
2.used to assign avalue to a variable Data Types, Variables and Expressions
3.Ex. int a=5;
== 60.What are the categories of Data types?
1.It is a relational operator. In C++, the data types are classified as three main categories
2.used to compare two values will be either equal or not. (1) Fundamental data types
3.Ex. a==b (2) User-defined data types and
(3) Derived data types
4. Why is main function special?
Every C++ program must have a main() function.
C++ programs begin their execution from main() function.
The executable statements should be inside the main() function.
39
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
Predefined data types are Fundamental data types available with Because more fractions accommodated in double than in float type
C++. 5. What is the use of void data type?Ref.61
There are five fundamental data types in C++: char, int, float, 62.What are the Memory representation of Fundamental Data types
double and void. in C++?
int data type: C++ compiler allocates specific memory space for each and every
Integers are whole numbers without any fraction. data .
Integers can be positive or negative. Every data is stored inside the computer memory in the form of
Itaccepts and returns only integer numbers. binary digits
.Ex. int a = 5; int x = -4 ;
int a= 4.5 (it will accept only 4)
Evaluate Yourself….
40
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
Variables
65.Define variables.
Variables are user-defined names.
Variables are memory locations in which the values are stored.
Variables are also identifiers.
These are called as symbolic variable because these are named
location.
They are R-value and L-value.
Floating point type • R-value is data stored in a memory location
• L-value is the memory address .
The memory addresses are in the form of Hexadecimal values
Ex.Let int a = 5; Here Variable name is a ;R value is 5 ; L value is
0x12b(for example)
41
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
42
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
43
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
45
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
12.Explain conditional operator with an example. default: cout<<"\n , You have Failed..";
The conditional operator(?:) (or) Ternary operatoris an alternative } }
for „if else statement‟. output
It takes three operands. Enter your Mark 79
Syntax:Condition ? expression 2 : expression 3 You scored 79%
First division
Working of a program
* If x=76
* case 7 statement will execute directly and terminated by break;
if the condition is true (Non-zero),
* If switch expression gets other then the case value default statement
then the control is transferred to expression 2, otherwise, the
will execute
control passes to expression 3.
Example:
14.Differentiate between switch and if…else statement.
#include<iostream>
if…else switch
using namespace std;
Condition/ Expression decide Condition/Expression decide
int main()
whether if block or else block is which case to execute
{
execute.
inta,b,g;
cin>>a>>b; Uses multipleexpression for Uses singleexpression for
g=(a>b)?a:b; multiple choices. multiple choices
cout<<g<<" IS GREATER"; logical expressionchecks only for expression
return 0; It evaluates integer ,char It evaluate only char,int and enum
} ,float,pointer or Boolean data data type
13.Explain switch statement with an example. (or) type
Write the syntax and purpose of switch statement. If expression is false, else If expression is false, default
The switch statement is a multi-waybranch statement. statement will be execute. statement will be execute.
Based on a condition, the control is transferred to one of the many Difficult to edit Easy to Edit
possible points.
It replaces else if statement. 15.Explain an Iteration or Loop statements ( or )
Syntax: Define Iteration Statements
switch (expression/variable) It is also called Looping Statement.
{ An Iteration statement is a set of statements that are
case 1 : action block 1; break; repeatedly executed until a condition is TRUE.
case 2 : action block 2; break; It is also calledcontrol flow statements.
default : action block 3; C++ supports three types of iteration statements.
} They are, i) for ii) while iii) do…while
When expression value matches against the casevalue, 16.Explain the Parts of a loop.
that respective set of statements are executed. Every loop has four elements .They are
Otherwise, the defaultstatement isexecuted. Initialization expression
Example: Test expression
#include<iostream> Update expression
using namespace std; The body of the loop
int main() Initialization expression(s):
{ The control variable(s) must be initializedbefore enters into loop.
intp,x; It is executed only once in the beginning of the loop.
cout<<"\n Enter your mark "; Test Expression:
cin>>p; If condition is TRUE, the loop-body will be executeotherwise the
cout<<" \nYou scored "<<p<<"%\n"; loop is terminated.
x=p/10; Update expression:
switch( x ) used to change the value of the control variable.
{ The body of the loop:
case 10: case 9: case 8: cout<<"\nDistinction" ; break; Set of statements forms a body of the loop that are executed
case 7: case 6 : cout<<"\nFirst division" ; break; repetitively.
case 5:cout<<"\nSecond division" ; break;
case 4: cout<<"\nThird division" ; break;
46
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
17.What are the difference between Entry controlled loop and Exit 22.Define infinite loop.
controlled loop?. If condition is absent in a for loop is called infinite loop.Ex. for(i=0; ;
Entry controlled Exit controlled ++i) ( or ) for( ; ; )
Test-expression/condition is Test-expression/condition is
placed at the beginning of the placed at the end of the body of 23.Differentiate between empty and infinite loop . Ref above ans
body of the loop the loop 24.What is the output of the following code?
First the test-expression is First the body of the loop is inti;
evaluated. executed for(i=0;i<=5;i++);
The body of loop will be The body of loop will be executed { cout<< “ We are Indians”; }
executedonly when condition is at least one time It is an empty loop
true The body of loop contains a null statement(;)
Ex.for , while do…while 25.Explain While loop with an example.
18.Explain for loop with an example It isan Entry controlled loop.
It is an Entry controlled loop. The condition (Test –Expression) placed at the beginning of the
Test-expression/condition is placed at the beginning of the body body of the loop.
of the loop Syntax:
for loop contains initialization , test expression and update Initialization;
expression but these are optional. while ( Test expression )
Syntax: {
for(Initialization ; test-Expression ; update expression) Body of the loop;
{ Update expression;
Statements; }
} General working for loop
General working for loop 1.First the control variable is initialized
1.First thecontrol variable is initialized 2. If the condition is false, the control exit from loop.
2.If the condition is false, the control exit from loop. 4. If the condition is true, the body of the loop is
4.If the condition is true, the body of the loop is executed,
executed, 5. Next the control is to update expression.
5. Next the control is to update expression. 6.After this, the control is again transferred to the condition.
6.After this, the control is again transferred to the condition. Example:
7.Next the steps 3 to 5 is repeated. #Include<iostream>
Example: using namespace std;
#Include<iostream> int main()
using namespace std; {
int main() int n=1;
) while(n<5)
{ {
for(int n=1;n<5;n++) cout<<n;
{ n++;
cout<<n }
} }
} Output: 1234
Output
1234 26.What is the following code?
19.Why always prefer prefix increment/decrement operator over int main()
postfix when to be used alone? {
Because prefix operators are executed faster than postfix. inti=0;
20.Give an example of infinity loop and empty loop while(++i<100)
for( inti=0 ;; i++) - infinity loop return 0; }
for( ; ; ) - infinity loop This is empty loop
21.What is an empty loop? It does not contain any statement.
Empty loop means a loop has no statement in its body is called an
empty loop.
Ex.for( inti=0 ; i<4 ; i++);
The body of loop contains a null statement(;)
47
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
27.What is the output of the following code? 29.Explain Nesting of Loop with an example.
int main() A loop which contains another loop is called as a nested loop.
{ The inner loop must be completely nestedinside the body of the
inti=0; outer loop.
while(i<100) An outer loop and inner loop cannot have the same control
cout<<I; variable, as it will lead to logical errors.
return 0; Syntax:
} Loop 1() for(int i = 1; i<= 3; i++)
It is an infinity loop { {
Because no update statement Loop 2() int j = 1;
{ while (j <= i)
28.Explain do..while loop with an example. block 2; {
do.. while is an Exit controlled loop, } cout<< “* “;
The condition placed at the end of the body of loop. block 1; j++;
The body of loop will be executed at least one time. } }
Syntax: cout<< ‘\n’;
Initialization; }
do
{ working of the above program:
statement; The iterations of the nested loops are as follows;
update expression; For loop While loop
} while (condition); I=1 Is executed once(j<=1)
I=2 Is executed twice (j=1,2)
General working do..while loop I=3 Is executed thrice(j=1,2,3)
1.Firstthe control variable is initialized. 30.Define jump statements
2.The body of the loop is executed, and update expression. It is used to transfer the control from one part of the program to
3.Then to condition. another with out condition. They are,
4 .If the condition is false, the control exit from loop. gotostatement
5. If the condition is true, the body of the loop is break statement
executed, . continue statement
Example 31.Explain goto statement with an example (or) explain
#Include<iostream> unconditional statement in C++.
using namespace std; It is an unconditional statement.
int main() It is used to transfer the control from one part of the program to
{ another with out condition.
Int n=1; Syntax:
do goto label; Syntax
{ cout<<n ………………. Label:
n++; ……………….. …..
}while(n <3); ………………. ……..
} Label: goto Label;
Return o;
} Here ,
Label is an identifier.
When gotolabel; is encountered, the control of program jumps
to label: and executes the code below it.
Example:
#Include<iostream>
using namespace std;
int main()
{
inta,b;
cin>>a>>b;
if(a>b)
goto true;
48
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
49
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
Write a program to find the LCM and GDC of two numbers 2. In C++, the group of statements should enclosed within:
include<iostream> (A) { } (B) [ ] (C) ( ) (D) <>
using namespace std;
int main() 3. The set of statements that are executed again and again in iteration is
{ called as: (A) condition (B) loop (C) statement (D) body of loop
int n1,n2,a,b,gcd,lcm;
cin>>n1>>n2; 4. The multi way branching statement:
a=n1; (A) if (B) if … else (C) switch (D) for
b=n2;
while(n1!=n2) 5. How many types of iteration statements?
{ (A) 2 (B) 3 (C) 4 (D) 5
if(n1>n2)
n1=n1-n2; 6. How many times the following loop will execute? for (inti=0; i<10; i++)
else (A) 0 (B) 10 (C) 9 (D) 11
n2=n2-n1;
} 7. Which of the following is the exit control loop?
gcd=n1; (A) for (B) while (C) do…while (D) if…else
cout<<"GCD"<<gcd;
lcm=(a*b)/gcd; 8. Identify the odd one from the keywords of jump statements:
cout<<"LCM"<<lcm; (A) break (B) switch (C) goto (D) continue
return 0;
} 9. Which of the following is the exit control loop?
(A) do-while (B) for (C) while (D) if-else
Write a program to find sum of the series
S = 1 + x + x2 +..... + xn 10. A loop that contains another loop inside its body:
#include<iostream> (A) Nested loop (B) Inner loop (C) Inline loop (D) Nesting of loop
#include<math.h>
using namespace std;
int main()
{
intx,n,i,s=0;
51
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
The returned value is either in double, float, or long double. statement. definition
sqrt() The constant, variables or Only data type with variables are
The sqrt() function returns the square root of the expressions are used. used
given value of the argument.
It takes a single positive value only,otherwise a domain error
occurs. 15.How to access a function?
sin() A function can be called or invoked from another
The sin() function takes a single argument in radians. function by using its name and the required
It returns the value in the range of [-1, 1]. arguments.
The returned value is either in double, float, or long double. The compiler refers to the function prototype to
pow() check whether the function has been called
The pow() function returns the power of exponent. correctly.
The returned value is either in double, float, or long double. If the argument type does not match exactly with
The pow() function takes two arguments: the prototype, the compiler will perform type conversion, if
1. base 2. exponent possible.
Syntax: pow(base,exponent) ;Ex . pow(3,2); otherwise, the compiler generates an error message.
9.Define Function Definition. Ex . swap(x,y);
A function must be defined before it is used
anywhere in the program. 16.Explain Default arguments with an example.
Syntax: The default value is given in the form of variable
Return_Data_TypeFunction_name(parameter list) initialization. Ex : void area (int n1=10, n2=100);
{ The default arguments facilitate the function call
Body of the function statement with partial or no arguments.
} The default values can be included in the function
10.Define function prototype. prototype from right to left,
Functions should be declared before they are used in a program. Default value cannot be include between the
function prototype is used to declare a function . argumentlist.
The declaration statement may be given outside the main() Ex : void area (int n1=10, n2);//invalid prototype
function. void area(int n1, n2 = 10);//valid prototype
It helps the compiler to check the data requirementof the function. Example
syntax Return type function name(arguments); #include <iostream >
11.What are the information the prototype provides to the compiler ? using namespace std; Output:
The prototype provides the following information to the int area (int l = 10, int b=20)
compiler: { return (l * b); } 80
1.Number and type of arguments void main ( )
2.The type of return values { int s1 = 4, s2 = 6;
3.Name of the function. cout<<area (s1);
syntax Return type function name(arguments); }
12.Write the information to the compiler from the 17.Define constant argument. What is const modifier?
following prototype. long fact(int a ,double b); const Keyword used to declared the constant variable.
The return data type is long. It enables to assign an initialvalue to a variable
fact is the name of the function. value cannot be changed.
The function is called with two arguments: Syntax : const datatype variable=value;
The first argument is of int data type. Example: const int a=10;
The second argument is of double data type.
13.What are the uses of void ? 18.Explain the Methods of calling functions.
To indicate the function does not return a value What are the different ways of passing parameters in
To declare a generic pointer. C++ functions?
Ex. void fun(void) The call statement communicates with the function
14.Differentiate between actual parameters and formal parameters. through arguments or parameters.
Actual parameters Formal parameters There are two ways of passing parameters in C++
Parameters The parameters associated functions .
associated with call with function header. 1.Call by value 2. Call by reference.
statement.
It is within calling It is within function 19.Explain call by value in C++ with an example.
52
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
The formal parameter creates new variables and stores the memory space.
value from actual parameter • Reduce the complexity of using STACKS.
This method copies the values of actual parameters into the formal Ex.
parameters #include <iostream >
Any change in the formal parameter is not reflectedback to the using namespace std;
actual parameter. inline void swap (int a)
Ex. { a=8;
#include <iostream > cout<< „\n‟<< a;
using namespace std; }
void swap (int a) int main ( )
{ a=8; {
cout<< „\n‟<< a; int m1 = 10;
} cout<<m1 ;
int main ( ) swap (m1);
{ cout<< „\n‟<< m1;
int m1 = 10; }
cout<<m1 ;
53
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
3. A Function without return value and with parameter char name(); char
#include <iostream > 25.Explain the Returning non integer values(string) in C++?
using namespace std; #include <iostream >
void display( int a) using namespace std;
{ char *display()
cout<<a; { return („‟Chennai‟‟); }
cout<<"Without return value& with parameter "; int main()
} {
int main() Char a[10];
{ Cout<<display();
int x=10; }
display(a); Output: Chennai
} 26.What is Recursive function ?
Function name: display() A function that calls itself is known as recursive function.
Return data type: void Example:
Argument: one parameters (int a) int add(inta,int b)
{
4. A Function with return value and with parameter ……
#include <iostream > …..add(a,a+b);
using namespace std; }
int display( int a) void main()
{ {
Int b=5 add(x,y);
Int c=a+b; }
cout<<"With return value& with parameter "; 27.Explain about the different scopes of a variable in
return c; C++ with an example.
} Scope refers to the accessibility of a variable.
void main() There are four types of scopes in C++.
{ They are: 1. Local scope, 2. Function scope, 3. File
int x=10; scope 4.Class scope
cout<< display(a); 1. Local scope
} A local variable is defined within a local block.
Function name: display() A local variable cannot be accessed from outside the block.
Return data type: int A block of code begins and ends with curly braces{ }.
Argument: one parameters (int a) It is created upon entry into its block and remove upon exit .
The return statement returns with c value to the
calling statement 2. Function scope
23.Define return statement in C++. The variable declared within afunction
The return statement is used to return from a The scope of variable is extended to the functionblock, and all sub-
function to the calling function. blocks.
It is a jump statement. The life time of a function scope variable, is the lifetime of the
A return may or may not have a value associated function block.
with it. Formal parameter is a function scope
A return statement without parameter can be used
to terminate the function.
Syntax: return expression/variable; 3. File scope
Example : return(a+b); return(a); return; It is also called as globalvariable.
24.Explain the returning value in C++? declared above main ( ).
The functions that return no value is declared as The life time of a file scope variable is the life time of a program.
void. #include <iostream >
Default return data type is int. using namespace std;
if no data type is explicitly mentioned, it is treated as int. Int b=10;
Ex. int add (int, int); add (int, int); void swap (int a)
In both prototypes, the return value is int, { int c = a+b;
float area(float); float cout<< c;
54
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
class name
{
Private:
{ declaration; }
Protected:
{ declaration; }
Public:
{ declaration; }
};
An array is a collection of variables of the same type that are 6.How to Accessing array elements
referenced by a common name. Array elements can be used anywhere in a program like a
It is derived data type. normal variable.
There are different types of arrays used in C++. They are: The elements of an array are accessed with the array name
One-dimensional arrays followed by the subscript index within the square bracket.
Two-dimensional arrays Ex. cout<<num[3];
Multi-dimensional arrays The following for statement is used to display the values.
2.Define One-dimensional array for(inti=0; i<5; i++)
This is the simplest form of an array. {
A one dimensional array represents values that are stored in a cout<<num[i];
single row or in a single column. }
Declaration 7.What is Traversal in an Array?
Syntax: Accessing each element of an array at least once to perform
data type array_name [size]; any operation is known as “Traversal”.
Example: Displaying all the elements in an array is an example of
int num[10]; “traversal”.
3.State the following array declaration are valid or Invalid. 8.What are strings? Give an example.What is Array of Characters?
(a)int array [100.5]; - invalid A string is defined as a sequence of characters where each
(b)int a [10]; - valid character may be a letter,number or a symbol.
(c)char name [15]; - valid Each element occupies one byte of memory.
(d)const j = 15; double val [ j ]; - valid Every string is terminated by a null („\0‟)
(e)int d[ ] ={ 1, 2, 3, 4, 5, 6, 7 } - valid a string as an one-dimensional character array.
4.Write a statement for the following. To declare Character array
(a) Read 6 th element = cin>> n [5] Syntax: char array_name[size];
(b)assigns the contents of the 4 th element of the array to its 5 th #include <iostream>
element = n [4] = n [3] void main()
(c) increments the value stored as 5 th element by 1 = n [4] ++ {
5.Explain the types of Array Initialization char country[6];
An array can be initialized at the time of its declaration. cin>>country;
Unless an array is initialized, all the array elements contain cout<<" The name of the country is "<<country;
garbage values. }
Syntax: OUTPUT
Datatypearray_name [size] = {val-1,val-2,. ,val-n}; INDIA
int a[3] = { 2,3,4); The name of the country is INDIA
a[1] = 5; a[0]= 10;
More examples of array initialization: 9.How to Initialize one dimension character array ?
float x[5] = {5.6, 5.7, 5.8, 5.9, 6.1}; The character array can be initialized at the time of its
char vowel[6] = {'a', 'e', 'i', 'o', 'u', '\0'}; declaration. The syntax is shown below:
Accepting values to an array during run time : by using cin char a_nam[size]={ list of characters separated by comma or a
cin>>a[2] ; string } ;
using loop char country[6]=“INDIA”;
#include <iostream> char country[6]={„I‟, „N‟, „D‟, „I‟, „A‟, „\0‟};
using namespace std; char country[]=“INDIA”;
int main() char country[]={„I‟, „N‟, „D‟, „I‟, „A‟, „\0‟};
{ Example
int num[5]; Char a[5] ={ „b‟,‟e‟,‟4‟}
a[0] --- b
a[1] --- e
for(inti=0; i<5; i++) a[2]--- 4
{ a[3] --- NULL
cin>>num[i]; A[4] ----NULL
} Char b[2] ={ „b‟,‟e‟,‟4‟} -- invalid(array elements cannot be initialized
} more than its size)
In the above program, a for loop has been constructed to execute the 12.Define Two-dimensional array
statements within the loop for 5 times.
56
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
Two-dimensional (2D) arrays are collection of similar elements using namespace std;
where the elements are stored in certain number of rows and inti;
columns. int main()
ex.int arr[3][3]; {
13.How to Declare 2-D array in C++? Write the syntax of int m1[10][10], m2[10][10], sub[10][10];
Declaration of 2-D array. cout<< "Enter the elements of first matrix:\n ";
data-type array_name[row-size][col-size]; for (i = 0;i<2;i++ )
Ex. int a[3][4]; for (j = 0;j<2;j++ )
Array size must be Positiveinteger value cin>>m1[i][j];
In arrays, column size is compulsory but row size is optional. cout<< "Enter the elements of second matrix:\n ";
14.How to calculate the size of the array? for (i = 0;i<2;i++ )
one dimension array size = memory required (data type ) x No. of the for (j = 0;j<2;j++ )
elements in the array cin>>m2[i][j];
Ex. int n[5] = 2 x 5 = 10 bytes ( one integer is 2 bytes) cout<<"Output: \n";
Two dimension array = Number of elements (Row x column ) x memory for (i = 0;i<2;i++ )
required for (j = 0;j<2;j++ )
Ex. int n [2] [3] = (2 x 3) x 2 = 12 bytes {
15.How to initialize a two dimensional array . sub[i][j]=m1[i][j] + m2[i][j];
The array can be initialized in more than one way at the time of 2-D cout<<sub[i][j]<<‟\t‟;
array declaration. }
Ex. int a [2][2] = { {1,2},{3,4}}; }
Array‟s row size is optional but column size is compulsory. getch();
Accessing the two-dimensional array }
A[0][1] = 10; assign 10 to 2 nd element of first row 21.Write a C++ program to find the difference between two matrix.
16.Define Memory representation of 2-D array #include <iostream>
A 2-D array is stored in sequential memory blocks. using namespace std;
There are two types of 2-D array memory representations. They inti;
are: int main()
Row-Major order {
All the elements are stored row by row in continuous memory int m1[10][10], m2[10][10], sum[10][10];
locations, cout<< "Enter the elements of first matrix:\n ";
Column-Major order for (i = 0;i<2;i++ )
All the elements are stored column by column in continuous for (j = 0;j<2;j++ )
memory locations, cin>>m1[i][j];
17.What is array of string? cout<< "Enter the elements of second matrix:\n ";
Set of strings for (i = 0;i<2;i++ )
An array of strings is a two-dimensional character array. for (j = 0;j<2;j++ )
The size of first index (rows) determines the number of strings and cin>>m2[i][j];
the size of second index determines maximum length of each cout<<"Output: \n";
string. for (i = 0;i<2;i++ )
Ex. char day[2][10] ={“Sunday \0”,“Monday\0”}; for (j = 0;j<2;j++ )
S u n d a y \0 {
sum[i][j]=m1[i][j]-m2[i][j];
M 0 n d a y \0
cout<<sum[i][j]<<‟\t‟;
}
}getch();}
18.Write a C++ program to accept and print your Name.
Structures …
#include <iostream>
using namespace std;
int main()
22.What is Structure? Or Define Structure.
{
Structure is a user-defined data type.
char n[]=”ELANGO”;
This allows to group of variables with different data types
cout<<”Myname is …”<<n;
together into a single unit.
}
23. Declaring and defining structures
20.Write a C++ program to find the sum of two matrix.
Structure is declared using the keyword „struct‟.
#include <iostream>
57
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
58
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
1.What is paradigm ?Mention the different types of paradigm? The members and functions declared under private are not
Paradigm means organizing principle of a program. accessible by members outside the class, this is referred to data
It is an approach to programming hiding.
They are Procedural programming, Modular Programming and 9.Differentiate classes and objects.
Object Oriented Programming Class object
2.How is modular programming different from procedural Class is a way to bind the data Represents data and its
programming paradigm? and its associatedfunctions associated function together
together. into a single unit.
Modular programming Procedural programming
Emphasis on algorithm rather This emphasis on doing things. User defined data type They are instances of
than data Class ( class variable)
Programs are divided into Programs are organized into Class represents a group Basically an object
individual modules subroutines or sub programs of similar objects is created from a class.
Each modules are independent All data items are global
and have their own local data
Modules can work with its own Difficult to maintain and 10.What is polymorphism?
data enhance theprogram code . Polymorphism is the ability of a message or function to be
Ex.Pascal and C Ex. FORTRAN and COBOL. displayed in more than oneform.
3.Write the differences between Object Oriented Programming and 11.What are the Advantages of OOP
procedural programming Re-usability:
Code can be use any number of times.
Modular programming Object Oriented Programming Redundancy:
Emphasis on algorithm rather Emphasizes on data rather Inheritance is the good feature for data redundancy.
than data than algorithm Easy Maintenance:
Programs are divided into Data and its associated It is easy to maintain and modify existing code
individual modules operations are Security:
grouped in to single unit Data hiding and abstraction are used to give the security of data.
Each modules are independent Data abstraction is introduced 12.Write the disadvantages of OOP.
and have their own local data Size:
Modules can work with its own Relationships can becreated Object Oriented Programs are much larger than other programs.
data. between similar Effort:
Object Oriented Programs require a lot of work to create.
Ex.Pascal and C Ex.C++, Java, VB.Net, Python Speed:
etc. Object Oriented Programs are slower than other programs, because
of their size.
4.What are the Main Features of Object Oriented 13.What is Modularity ?
Programming? Advantages of oop. Programs aredivided into individual modules is called
Data Abstraction Modularity.
Encapsulation 14.Define Software re-use:
Modularity A program can be composed from existing and newmodules
Inheritance
Polymorphism
5.How is encapsulation and abstraction are interrelated? Or
6.Define encapsulation.
The mechanism by which the data and functions are bound
together into a single unit is known as Encapsulation
It can also be called data binding.
7.Define Abstraction
Abstraction refers to showing only the essential features
without revealing background details
8.Define Data Hiding or information Hiding.
60
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
61
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
62
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
18.Explain how the objects can be passed in pass by reference void square()
method. {
object in formal parameter alias the object of actual parameter. n.prn();
The formal object works directly on the actual object. x=2;
Any changes made to the object inside the formal parameter cout<< x * x;
,affect the actual object. }
#include <iostream> };
using namespace std;
class sample int main()
{ {
private: enclose e;
public: e.square();
void pass(sample &obj) }
{
-------- In the above program
} The inner class nest is defined inside the outer class enclose.
}; nest is accessed by enclose by creating an object of nest
int main()
{ Declaring an object of a class as a member to another class
sample s1,s2; Whenever an object of a class is declared as a member of another
s2.pass(s1); class it is known as a container class.
return 0; In the container-ship the object of one class is declared in another
} class.
19.What is nested class? #include<iostream>
When one class become the member of another class then it is using namespace std;
called Nested class. class outer
20.What are the ways the classes can be nested? {
Classes can be nested in two ways. int data;
1. Defining a class within another class public:
2. Declaring an object of a class as a member to another class void get();
Defining a class with in another };
When a class is declared with in another class, class inner
The inner class is called as Nested class . {
The outer class is known as Enclosing class. int value;
Nested class can be defined in private as well as in the public outer ot;
section of the Enclosing class. public:
#include<iostream> voidgetdata();
using namespace std; };
class enclose Intmain()
{ {
private: Inner x;
int x; }
class nest In the above program
{ Classouter and inner are defined separately.
private : But both the classes areconnected by the object 'ot' which is a
int y; member of class inner.
public: 21.What is Container class?
void prn() Whenever an object of a class is declared as a member of another
{ class it is known as a container class.
y=3; 22.Write the example how will you dynamically initialize objects?
cout<<y; When the initial values are provided during runtime is called
} dynamic initialization.
}; Example
nest n; #include<iostream>
public: using namespace std;
63
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
64
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
65
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
66
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
12.List out the operators that cannot be overload in C++ Rules or Restrictions on Operator Overloading
scope operator (:: ) Precedence and Associativity of an operator cannot be changed.
sizeof No new operators can be created,
member selector ( . ) Only existing operators can be overloaded.
member pointer selector (* ) Cannot redefine the meaning of an operator‟s procedure.
ternary operator ( ?: ) Overloaded operators cannot have default arguments.
13.How to define operator overload in C++ When binary operators are overloaded, the left hand object must be
The definition of the overloaded operator is given using the keyword an object of the relevant class
'operator' followed by an operator symbol.
Syntax:
Inline:
ReturnType operator operatorSymbol(argument)
{
}
Ex. complex operator +( complex c2)
{
}
Outline:
ReturnTypeclassname : : operator operatorSymbol(argument)
{
}
67
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
3. Hierarchical inheritance
When more than one derived classes are
created from a single base class ,it is
known as Hierarchical inheritance.
Protected visibility mode
4. Multilevel Inheritance
When a base class is inherited with protected visibility.
The transitive nature of inheritance.
The protected and public members of the base class become
In multilevel inheritance a derived class
„protected members „ of the derived class
itself acts as a base classto derive
another class.
5. Hybrid inheritance
A combination of more than one type of
inheritance is known as hybrid inheritance.
It may be a combination of Multilevel and Multiple
or Hierarchical and Multilevel or Hierarchical,
68
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
69
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
}
12.WriteSome Facts about the execution of constructor in Output:
inheritance. Constructor of base class...
Base class constructors are executed first ,before the derived Constructor of derived ...
class constructors execution Constructor of derived1 ...
Derived class can not inherit the base class constructor. Destructor of derived1 ...
If there are multiple base classes ,then its start executing from the
Destructor of derived ...
left most base class
In multilevel inheritance, the constructors will be executed in the
Destructor of base class....
order of inheritance
14.How the size of derived class object is calculated?
13.Find the output of the following program.
#include<iostream>
Size of derived class object =
using namespace std;
Size of all base class data members + size of all derived class data
classbase
members.
{
15.What do you mean by overriding /Shadowing?
public:
When a derived class member function has the same name as
base()
that of its base class member function ,
{
The derived class member function shadows/hides the base
cout<<"\nConstructor of base class...";
}
class‟s inherited function .
~base() This situation is called function overriding /Shadowing .
{ This can be resolved by giving the base class name followed by ::
cout<<"\nDestructor of base class.... "; and the member function name
} Ex.employee :: display();
};
Classderived:public base 16.Define“this” pointer
{ this pointer used to refer the current objects members
public : 'this' pointer is a constant pointer that holds the memory address
derived()
of the current object. .
{ It identifies the currently calling object.
cout<< "\nConstructor of derived ..."; It is useful when the argument variable name in the member
function and the data member name are same. Syntax: this->data
}
member name
~derived()
{ #include<iostream>
cout<< "\nDestructor of derived ..."; using namespace std;
} class T
}; {
class derived1 :public derived public:
int x;
{
void foo()
public : {
derived1() x = 6; // same as this->x = 6;
{ this->x = 5; // explicit use of this->
cout<< "\nConstructor of derived1 ..."; cout<<endl<<x<<" "<<this->x;
}
}
void foo(int x)
~derived1() {
{ this->x = x; // unqualified x refers to the parameter.'this->' required
cout<< "\nDestructor of derived1 ..."; for disambiguation
} cout<<endl<<x<<" "<<this->x;
}; }};
int main()
{
derived1 x;
return 0;
70
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
Constructor of publisher
Constructor of branch
17.Answer the following questions based on the given program. Constructor of author
#include<iostream> Destructor of author
#include<string.h> Destructor ofbranch
#include<stdio.h> Destructor of publisher
usingnamespacestd; d. Name the base class(/es) and derived class (/es).
class publisher Base class: publisher, branchDerivedclass:author
{ e. Give number of bytes to be occupied by the object of the following
charpname[15]; class: (a) publisher (b) branch (c) author
charhoffice[15]; publisher:93 bytes branch:64 bytes author: 28 bytes
char address[25]; f. Write the names of data members accessible from the object of class
double turnover; author.
protected: Phone,no_of_emp, bphone,aut_code,aname,income
char phone[3][1O]; g. Write the names of all member functions accessible from the object of
void register(); class author.
public: getdata(),putdata(),give data(),have data(),disp data(), enter data();
publisher(); h. Write the names of all members accessible from member functionsof
~publisher(); class author
void enter data(); getdata(),putdata(),give data(),have data(),disp data(), enter
voiddisp data(); data(),register()
}; Phone,no_of_emp, bphone,aut_code,aname,income
class branch 18.Consider the following c++ code and answer the questions
{
class Personal
charbcity[15]; {
charbaddress[25]; IntClass,Rno;
protected: char Section;
intno_of_emp; protected:
public: char Name[20];
charbphone[2][10]; public:
branch(); personal();
~branch(); voidpentry();
void have data(); voidPdisplay();
void give data(); };
};
ClassMarks:private Personal
{
class author: public branch, publisher float M{5};
{ protected:
Intaut_code; char Grade[5];
Charaname[2O]; public:
float income; Marks();
public: void M entry();
author(); void M display();
~author(); };
voidgetdata(); classResult:public Marks
voidputdata(); {
};
floatTotal,Agg;
public:
charFinalGrade, Commence[20];
a.Which type of Inheritance is shown in the program?
Result();
Multiple inheritance void R calculate();
b.Specify the visibility mode of base classes. void R display();
public: }:
c. Give the sequence of Constructor/Destructor Invocation when object a. Which type of Inheritance is shown in the program?
of class author is created.
71
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
72
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
}
}
Class B:: public A()
{
PUBLIC
voidfunc()
{
int b1:b2:b3;
A::getdata[];
b1=a1;
b2=a2;
a3=a3;
cout<<b1<<‟\t‟<<b2<<‟t\‟<<b3;
}
void main()
{
clrscr()
B der;
der1:func();
getch();
}
To Know Yourself
Define Pointer variable
A pointer is a variable that hold a memory address of other variable
In Pointer ,the memory location of a variable can be directly
accessed.
The address of ( & ) and the value at operator (*)are deals with
pointer.
To declare
Syntax :data type *Variable name;
Ex. Int *abc;- Here The variable abc can only
store addresses.
Initialization of pointer variable:
Int *abc , n;
n=10;
abc = &n;
Pointer variable can store the address of other variables
Pointer variable and assigning variable should have same data type.
---------------------------------------------------
For example
Int *abc ; float n;
n=10.5;
abc = &n;
Compiler shows an error because,
Pointer variable and assigning variable should have same data type
==============================================
73
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
74
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
75
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
2.Define e – Governance:
Getting Government services through internet is known as e-Governance.
One can get important announcements, government orders, and
government welfare schemes from the web portal of Govt.
Ex.www.tn.gov.in\ta
3.Define e-Library
E-Libraries are portal or website of collection of e-books.
E-Library services provide thousands of Books as e-books mostly at free
of cost.
Ex.www.chennailibrary.com
76
www.rmkmhsselango.blogspot.com 9677515019
ILANGOVAN ,RMKMHSS - 601206 9677515019
E.ElangovanM.Sc;B.Ed;M.Phill;P.G.D.C.A;
11/100.B.K.Puram,
Gummidipundi – 601201
[email protected]
rmkmhsselango.blogspot.com
9677515019
77
www.rmkmhsselango.blogspot.com 9677515019
11
COMPUTER SCIENCE
PRACTICAL
9677515019
www,rmkmhsselango.blogspot.com
ElangovanM.Sc,B.Ed,M.Phil
Head of the Dept.
R.M.K.Matric.Hr.Sce.School,
R.S.M.Nagar,601206.
CS1 - GROSS SALARY
Write a C++ program to input basic salary of an employee and calculate its Gross salary according to following:
Basic Salary <25000 : HRA = 20%, DA = 80%
Basic Salary >= 25000 : HRA = 25%, DA = 90%
Basic Salary >= 40000 : HRA = 30%, DA = 95%
AIM:
To input basic salary of an employee and calculate its Gross salary
CODING:
#include<iostream>
using namespace std;
int main()
{
floatb,g,d,h;
cout<<"Enter Basic Salary of an Employee"; cin>>b;
if (b<25000)
{
d=b*80/100;
h=b*20/100;
}
else if (b>=25000 && b<40000)
{
d=b*90/100;
h=b*25/100;
}
else if (b>=40000)
{
d=b*95/100;
h=b*30/100;
}
g=b+d+h;
cout<<"\nBasic\t"<<b;
cout<<"\nDA\t"<<d; Output:
cout<<"\nHRA\t"<<h; Enter basic salary of an employee: 25000
cout<<"\nGross Salary\t"<<g; Basic 25000
} DA 22500
HRA 6250
Gross Salary : 53750
CS2 - PERCENTAGE
Write a C++ program to check percentage of a student and display the division (distinction, first, second, third
or fail) scored using switch case.
Percentage Division
>=80 Distinction
>=60 and <80 First division
>=50 and <60 Second Division
>=40 and <50 Third Division
<40 Fail
AIM: To check percentage of a student and display the division
CODING:
#include<iostream>
using namespace std;
int main()
{
intp,x;
cout<<"\n Enter Your Percentage"; cin>>p;
cout<<" \nYou Scored "<<p<<"%\n";
x=p/10;
switch(x)
{
case 10: case 9: case 8:cout<<"\nDistinction";break;
case 7: case 6 :cout<<"\nFirst division";break;
case 5:cout<<"\nSecond division";break; Output 1
case 4:cout<<"\nThird division";break; Enter your percentage 79
You scored 79%
default:cout<<"\nSorry , You have Failed.."; First division
Output 2
} Enter your percentage: 39
You scored 39%
} Sorry: You have failed
CS3 - PALINDROME
Write a C++ program to enter any number and check whether the number is palindrome
or not using while loop.
AIM: To enter any number and check whether the number is palindrome
CODING:
#include<iostream>
using namespace std;
int main()
{
intn,x,d,r=0;
cout<<"\nEnter a Positive Number";
cin>>n;
x=n;
while(n!=0)
Output 1
{ Enter a positive number: 1234
r=(r*10)+n%10; The Reverse number is: 4321
NOT A PALINDROME
n=n/10;
} Output 2
Enter a positive number: 1221
cout<<"\nThe Reverse Number is "<<r; The Reverse number is: 1221
if(x==r) PALINDROME
cout<<"\nPALINDROME";
else
cout<<"\n NOT A PALINDROME";
}
CS4 NUMBER CONVERSION
Using do while loop create the following menu based C++ program
1.Convert a Decimal to binary number
2.Convert a binary number to Decimal
3. ExitDepending on the choice accept the value and display the result .The program should continue till the user
select the third option
AIM:To Convert a Decimal to binary number and a binary number to Decimal in menu based using do..while loop
CODING:
#include<iostream>
#include<math.h> Output
using namespace std; 1.Decimal to Binary number
int main() 2.Binary to Decimal number
{ 3.Exit
int d=0,c,i; Enter your choice(1/2/3)1
long int b=0; Enter a Decimal Number: 23
do In decimal … 10111
{
cout<<"\n1.Decimal to Binary\n2.Binary to Decimal\n3.Exit"; 1.Decimal to Binary number
cout<<"\nEnter Your Choice (1 / 2 / 3)"; 10
cin>>c; 2.Binary to Decimal number
switch(c) 3.Exit
{ Enter your choice(1/2/3)2
case 1:cout<<"\nEnter a Decimal Number"; Enter a Binary Number: 11001
cin>>d; In binary … 25
i=0;
while(d!=0) 1.Decimal to Binary number
{ 2.Binary to Decimal number
b+=d%2*pow(10,i); 3.Exit
d/=2; Enter your choice(1/2/3) 3
i++;
}
cout<<"\n In Binary “<<b; break;
case 2:cout<<"\nEnter a Binary number";
cin>>b;
i=0;
while(b!=0)
{
d+=b%10*pow(2,i);
b/=10;
i++;
}
cout<<"\n\n Decimal"<<d; break;
case 3: break;
default:cout<<"\nEnter only 1 / 2 / 3:";
}
} while(c!=3);
}
CS5 - FIBONACCI PRIME SERIES
Write a C++ program using a user defined function to generate the Fibonacci series till n terms and print if
each term is prime or Composite.
AIM: To generate the Fibonacci series till n terms and print if each term is prime or Composite
CODING:
#include <iostream>
#include <stdlib.h>
using namespace std;
void prime (int a )
{
if( a == 0 || a == 1 )cout<< "\tNEITHER PRIME NOR COMPOSITE ";
else
{
for (int j = 2 ; j<a; j++)
{
if(a%j==0){ cout<< "\tCOMPOSITE" ;break ; }
}
if( a==j )cout<< "\tPRIME" ;
} Output
} ENTER THE NUMBER OF TERMS 10
void fib ( int n ) FIBONACCI SERIES
{ 0 NEITHER PRIME NOR COMPOSITE
int a = -1 , b = 1 ,c=0 ; 1 NEITHER PRIME NOR COMPOSITE
for ( inti = 1 ; i<= n ; i++) 1 NEITHER PRIME NOR COMPOSITE
{ 2 PRIME
cout<<”\n”; 3 PRIME
c=a+b; 5 PRIME
cout<<c; 8 COMPOSITE
prime(c); 13 PRIME
a = b; 21 COMPOSITE
b=c; 34 COMPOSITE
}
}
int main ()
{
int n ;
cout<< " \n ENTER THE NUMBER OF TERMS " ;cin>> n ;
cout<< "\n FIBONACCI SERIES\n " ;
fib (n) ;
}
ABC PUBLISHERS
~~~~~~~~~~~~~~
INVOICE
~~~~~~~
==================================
Book Number : 1001
Title : C++Programming
Author Name : Balaguru
Price Per Book : 500
Total Amount : 1500
=================================
ABC PUBLISHERS
~~~~~~~~~~~~~~
INVOICE
~~~~~~~
==================================
Book Number : 1002
Title : CoreJava
Author Name : Xavier
Price Per Book : 250
Total Amount : 1250
==================================
CS9 - EMPLOYEE DETAILS USING CLASS
Create a C++ program to create a class employee containg the following members
AIM: To create a class employee contain the following members
Coding
#include<iostream>
using namespace std;
class emp{
public:
inteno;
char name[20], des[20];
void get(){
cout<<"Enter the employee number:";
cin>>eno;
cout<<"Enter the employee name:";25
cin>>name;
cout<<"Enter the designation:";
cin>>des;
}
};
class salary :public emp
{
floatbp,hra, da,pf,np;
public:
void get1()
{
cout<<"Enter the basic pay:";
cin>>bp;
cout<<"Enter the HouseRent Allowance:";
cin>>hra;
cout<<"Enter the Dearness Allowance :";
cin>>da;
cout<<"Enter the Provident Fund:";
cin>>pf;
}
void calculate()
{
np=bp+hra+ da -pf;
}
void display()
{
cout<<eno<<"\t"<<name<<"\t"<<des<<"\t"<<bp<<"\t"<<hra<<"\t"<<da<<"\t"<<pf<<"\
t"<<np<<"\n";
}
};
int main(){
inti, n;26
char ch;
salary s[10];
cout<<"Enter the number of employee:";
cin>>n;
for (i =0; i< n; i++){
s[i].get();
s[i].get1();
s[i].calculate();
}
cout<<"\n\t\t\tEmployee Details\n";
cout<<"\ne_no \t e_name\t des \t bp \t hra \t da \t pf \t np \n";
for (i =0; i< n; i++){
s[i].display();
}
return 0;
}
Output
Enter the number of employee:2
Enter the employee number:1201
Enter the employee name:Ramkumar
Enter the designation:Engineer
Enter the basic pay:50000
Enter the House Rent Allowance:10000
Enter the Dearness Allowance :5000
Enter the Provident Fund:1000