POP Module-1 Notes
POP Module-1 Notes
Module 1:
Introduction to C: Introduction to computers, input and output devices,
designing efficient programs. Introduction to C, Structure of C program, Files
used in a C program, Compilers, Compiling and executing C programs, variables,
constants, Input/output statements in C,
Textbook: Chapter 1.1-1.9, 2.1-2.2, 8.1 - 8.6 ,9.1-9.14
What is Computer?
• Computer is an electronic device, which takes input from the user in the form of
data and instructions.
• Once the computer receives the data, it waits for the user’s instructions to
process the data.
• On receiving the instructions from the user, the computer processes the data and
generates the output and displays it to the user.
• The data that is given as an input to the computer can be text, numerals, audio,
video and image etc
“An electronic device which accepts the data, performs the required
mathematical and logical operations at high speed and outputs the result”.
• Input: Sending the data and command to the computer is known as input.
Characteristics of computers:
• Speed: Computers can perform millions of operations per second. The speed
of computers is usually given in nanoseconds/picoseconds where 1ns= 1 x
10^-9 seconds and 1ps= 1 x 10^-12 seconds
• No IQ: Computers do not have any decision making abilities of their own.
They need guidance to perform various tasks.
For example, the date of birth is the data and calculating the age using date of birth
is information.
• A computer with Von Neumann Architecture stores data and instructions in the
same memory.
• There is a serial machine in which data and instructions are selected one at a time.
• Data and instructions are transferred to and from memory through shared data
bus.
• Since there is a single bus to carry data and instructions, process of execution
becomes slower.
Fig: Von Neumann Architecture with separate memory for instructions and data
• Instructions are selected serially from the instruction memory and executed in the
processor.
• When an instruction needs data, it is selected from the data memory and hence the
execution becomes faster.
History of Computers:
• The Electromagnetic relay was used as primary memory and punch cards were
used to store data and instructions.
Advantage:
Disadvantage:
Vacuum tubes
Generated lot of heat, Consumed lot of electricity, Bulky in size, required constant
maintenance, Limited commercial use and very expensive.
magnetic tapes and disks were used to store data and instructions. Transistors
Advantage: Consumed less electricity, Generated less heat, Faster cheaper and more
reliable, could be programmed using high and assembly level language, had faster
primary memory and larger secondary memory.
• Large Magnetic core memory was used as primary memory and magnetic tapes and
disks were used to store data and instructions.
Advantage: Faster and could perform one million transactions per second, Smaller,
cheaper and more reliable, Faster and larger primary and secondary memory, widely
used for scientific and business applications
• Semiconductors memory was used as primary memory and magnetic tapes and
floppy disks were used as portable storage devices.
• Programming was done in high level programming language such as C and C++.
Advantage: Smaller, cheaper, faster and more reliable, Consumer less electricity,
generated less heat, Used as General purpose computers, GUI’s made work with
computer easier, Widespread of computers to office and homes
• Semiconductors memory was used as primary memory and magnetic tapes and
floppy disks were used as portable storage devices.
• Programming was done in high level programming language such as Java, Python,
C#.
Advantage:
Smaller, cheaper, faster, powerful and more reliable, Consumer less power, generated
less heat, high-end features available.
Comparison table
Classification of Computers:
1) Supercomputers:
• It was first developed in 1980s to process large amounts of data and solve complex
scientific problems.
• They use parallel processing technology and can perform trillion calculations in a
second.
• They are used for weather forecasting, nuclear energy research, aircraft design,
automotive design, online banking etc.
2) Mainframe Computers:
• These are very expensive and need a very large clean room with air conditioning,
making them very costly to deploy.
Dumb terminals:
It consists of only monitor and keyboard and uses mainframe’s system CPU and
storage device.
Intelligent terminals:
It have their own processor and perform processing operations but do not have their
own storage space.
• They are also used in organizations such as banks, airline companies, universities
where large number of people access the data frequently.
• Examples of Mainframe computers are: IBM S/390, Control Data CYBER 176, and
Amdahl 580.
3) Minicomputers:
5. Some minicomputers are designed in such a way that it can be either used by single
user or multiple users.
4. Microcomputers:
The first microcomputer was designed by IBM in 1981 and was named as IBM-PC.
Desktop PCs:
Laptops:
Workstations:
• A workstation is nothing but a computer like a personal computer, but with more
powerful microprocessor and large, high resolution monitor for better quality of pictures
along with large amount of memory.
Advantages: High Resolution, Accelerated graphics cards- they are used in video
editing and animations, Powerful machines and used for architectural or engineering
design.
Network computers:
• Network computers have less processing power, memory, and storage than a desktop
computer.
• For example, some network computers are specifically designed to access data stored
on a network (including the Internet and intranet).
• Some network computers do not have any storage space and merely rely on the
network's server for data storage and processing tasks. The concept of network
computers had become popular in the mid-1990s
• Network computers that are specifically designed to access only the Internet or
intranet are often known as Internet PCs or Internet boxes.
• Some network computers used in homes do not even have a monitor. Such
computers may be connected to a television, which serves as the output device.
• The most common example of a home-based network computer is Web TV, which
enables the user to connect a television to the Internet.
• The Web TV is equipped with a special set-top box that is used to connect to the
Internet.
• The set-top box also provides controls to enable the user to navigate the Internet,
send and receive e-mails, and to perform other tasks on the network while watching
television.
• The other reason for the popularity of network computers is that they are cheaper to
purchase and maintain than PCs.
Smart phones:
• A smart phone is an electronic hand held device that has the functionality of a mobile
phone and PDA.
Advantages:
• Various software applications such as E-Mail, SMS, voice recognition, camera, etc..
• PC Compatibility.
Tablet Computers:
• It has all the features of a laptop and allows the user to write on the screen using
digital pen. This pen is called stylus. This pen is also used to tap on the icon so as to
select an item.
Advantages:
• They are very slim and light weight compared to laptops and hence they are portable.
Applications of Computers:
1. Word Processing: Word Processing software enables user to read and write
documents.
2. Internet: The internet is a network that connects the computers all over the world.
3. Digital video or Audio Composition: Computers make Audio and Video editing very
simple.
4. Desktop publishing: This software enables to create page layouts for entire books.
• Electronic banking: Also known as Cyber banking or online banking which supports
various banking activities conducted from home, business instead of physical bank
location.
7) Health care: In health care, it is used to store health records, surgical procedures for
better diagnosis and treatment.
10) Multimedia and Animation: which combines still images, moving images,
text, sound.
11) Legal System: Computers are used by lawyers to shorten the time required to
conduct legal precedent and case research.
12) Retail Business: Computers are used here to enter orders, calculate costs, and
print receipts.
13) Sports: Computers are used here to compile statistics, identify weak and
strong players, sell tickets etc.
14) Travel and Tourism: Computer are used to prepare tickets, monitor the train
or airplane route, and guide the plane to a safe landing.
15) Simulation: Supercomputers that can process enormous amount of data are
widely used in simulation tests.
16) Astronomy: Spacecrafts are usually monitored using computers that not only
keep a continuous record of the voyage and of the speed, directions, fuel and
temperature, but also suggest corrective actions when vehicle make a mistake.
18) Industry and Engineering: Computers are found in all kind of industry like
thermal power plants, oil refineries, chemical industry, Computer-aided designing,
Computer aided manufacturing.
20) Expert systems: Expert systems are used to automate the decision-making
process in a specific area, such as analyzing the credit histories for loan approval,
diagnosing a patient’s condition for prescribing an appropriate treatment.
• Storing data
• Processing data
• Displaying results
Input:
• The process of entering the data and instructions into the computer system is called
Input.
• The data and instructions can be entered by using different input devices such as
keyboard, mouse, scanner, and trackball.
• Note that computers understand binary language, which consists of only two symbols
(0 and 1), so it is the responsibility of the input devices to convert the input data into
binary codes.
Storage:
• Storage is the process of saving data and instructions permanently in the computer
so that they can be used for processing.
1. Primary storage
2. Secondary storage
1. Primary storage:
• Primary storage, also known as the main memory, is the storage area that is directly
accessible by the CPU at very high speeds.
• It is used to store the data and parts of programs, the intermediate results of
processing, and the recently generated results of jobs that are currently being worked on
by the computer.
• Another drawback of main memory is that it is volatile in nature; that is, as soon as
the computer is switched off, the information stored gets erased.
• Hence, it cannot be used as a permanent storage of useful data and programs for
future use. An example of primary storage is random access memory (RAM).
2. Secondary storage:
• Secondary storage is also known as auxiliary memory, this memory is just the
opposite of primary memory. It overcomes all the drawbacks of the primary storage area.
• It is cheaper, non-volatile, and used to permanently store data and programs of those
jobs that are not being currently executed by the CPU.
• Secondary memory supplements the limited storage capacity of the primary memory.
An example is the magnetic disk used to store data, such as C and D drives, for future
use.
Output:
• Output is the process of giving the result of data processing to the outside world
(external to the computer system).
• The results are given through output devices such as monitor, and printer.
• Since the computer accepts data only in binary form and the result of processing is
also in binary form, the result cannot be directly given to the user.
• The output devices, therefore, convert the results available in binary codes into a
human-readable language before displaying it to the user.
Control :
• The control unit (CU) is the central nervous system of the entire computer system. It
manages and controls all the components of the computer system.
• It is the CU that decides the manner in which instructions will be executed and
operations performed. It takes care of the step-by-step processing of all operations that
are performed in the computer.
• Note that the CPU is a combination of the arithmetic logic unit (ALU) and the CU. The
CPU is better known as the brain of the computer system because the entire processing
of data is done in the ALU, and the CU activates and monitors the operations of other
units (such as input, output, and storage) of the computer system.
Processing:
• The process of performing operations on the data as per the instructions specified by
the user (program) is called processing.
• Data and instructions are taken from the primary memory and transferred to the
ALU, which performs all sorts of calculations.
• The intermediate results of processing may be stored in the main memory, as they
might be required again.
• When the processing completes, the final result is then transferred to the main
memory.
• Hence, the data may move from main memory to the ALU multiple times before the
processing is over.
CPU:
• The CPU is the brain of the computer. It performs all calculations and controls the
devices connected to the computer system.
• The faster the CPU, the quicker programs can process the instructions.
RAM:
• A fast CPU is of no use if the computer does not have sufficient RAM.
• RAM is the computer's memory which stores information used by applications that
are currently being executed by the CPU.
• More memory means more applications can be executed at the same time without
degrading the system's performance.
• The HDD of the computer is the secondary memory of the computer system where
information is stored permanently.
• All types of data, documents, and programs are stored on the hard disk.
• The larger the hard disk, the more the amount of data that can be stored on the
drive.
• Though the size of the HDD does not affect the speed of execution of the program, it
does affect the speed at which the user can access his/ her files.
Video card:
• The video card is a board that plugs into the motherboard of the computer and
generates images for display.
• Many video cards these days have their own RAM and processor to enhance the
speed of the graphics display.
• In such a computer, a separate video card is used only if the computer has to be
used for high-end multimedia work or to play video games.
Sound card:
• As with video cards, sound cards are expansion boards that are used to enable a
computer to manipulate sound.
• For example, sound cards allow the users to plug in speakers and a microphone.
Some sound cards also provide the jacks for hooking your computer up to a common
stereo.
• These days, many computers come with a built-in sound chip, which makes it
unnecessary to buy a separate card unless a higher quality of sound is needed.
Modem:
Network card:
• A network card is used to connect the computer either to other computers or to the
Internet (in case you are using a fast Internet connection such as cable or DSL).
Fans:
• There are one or more fans inside the computer to keep the air moving and the
computer cool.
Cables:
• There are multiple wires inside the computer that are flat, ribbon-like cables.
• They are used to provide power and communication to the various parts inside the
computer.
Input devices:
Keyboard:
Advantages:
Disadvantages:
• The process of moving the cursor to another position is very slow. Mouse and other
pointing devices are more apt for this purpose.
Pointing devices:
• A pointing input device enables the users to easily control the movement of the
pointer to select items on a display screen, to select commands from commands menu,
to draw graphics, etc.
• Some examples of pointing devices include mouse, trackball, light pen, joystick, and
touchpad.
Mouse:
• The mouse is an input device that was invented by Douglas Engelbart in 1963.
• Mouse is a hand held device that allows a user to control the computer without
typing instructions from the keyboard.
• Point: Placing the pointer over the word or the object on the screen by moving
the mouse on the desk is termed as pointing.
• Drag: Dragging means pointing to a desired location while pressing the left
button.
• Click: Pressing either the left or the right button of the mouse is known as
clicking. Clicking a mouse button initiates some action; for example, when you
click the right button by pointing the mouse on a word, a menu pops up on the
screen. When you move the pointer over the icon of an application, say Internet
Explorer, and double-click on it, then it opens that application for you.
• Scroll: The scroll wheel, which is placed in between the left and right buttons of
the mouse, is used to vertically scroll through long documents.
The mouse is specially used to create graphics such as lines, curves, and freehand
shapes on the screen. It is connected to a serial or a universal serial bus (USB) port on
the system unit. Some of the popular mouse types are as follows:
1. Mechanical mouse
2. Optical mouse
3. Cordless mouse
1. Mechanical mouse
• This type of mouse has a rubber or metal ball at its bottom and an electronic circuit
containing sensors.
• When the mouse is moved over a flat surface, the sensors detect the direction of
movement of the ball.
• The electronic circuit translates the movement into signals and feeds it as input to
the computer.
2. Optical mouse: The optical mouse is more advanced than the mechanical mouse. It
contains a ball inside. The movement of the mouse is detected using laser technology, by
using optical sensors.
3. Cordless mouse: A cordless or wireless mouse is not connected to the computer. The
movement of the mouse is detected using radio waves or infrared light waves.
Advantages:
• Low Priced
• Easy to use and can be used to quickly place the cursor.
Disadvantages:
• Needs extra desk space to be placed and moved easily.
• The ball in the mechanical mouse must be cleaned to remove dust from it
Trackball:
• A trackball is a pointing device that is used to control the position of the cursor on
the screen.
• It is usually used in notebook computers, where it is placed on the keyboard
Advantages:
• Provides better resolutions.
• Occupies less space.
• Easier to use as compared to mouse as its use involves less hand and arm
movements.
Disadvantages: The trackball chamber is often covered with dust and must be cleaned
regularly.
Touchpad:
• A touchpad (or trackpad) is a small, flat, rectangular stationary pointing device with a
sensitive surface of 1.5-2 square inches.
• The user has to slide his or her fingertips across the surface of the pad to point to a
specific object on the screen.
• The surface translates the motion and position of the user's fingers to a relative
position on the screen.
Advantages:
• Occupies less space.
• Easy to use.
• Built in keyboard so need to carry an extra device.
Handheld devices:
• A handheld devices is a pocket-sized computing device with a display screen and
touch input and/or a miniature keyboard.
• Some examples are:
1. Smartphone's
2. PDA’s
Joystick:
• Joystick is a cursor control device widely used in computer games and CAD/CAM
applications.
• It consists of a hand-held lever that pivots on one end and transmits its coordinates
to a computer.
• It has one or more push-buttons, called switches, whose position can also be read by
the computer.
Stylus:
• A stylus is a pen-shaped input device used to enter information or write on the
touch screen of a phone.
• Stylus is a small stick that can also be used to draw lines on a surface as input to a
computer, choose an option from a menu, move the cursor to another location on the
screen, take notes and create short messages.
• The stylus usually slides into a slot built into the smart phone for that purpose.
Touch screen:
• A touch screen is a display screen which can identify the occurrence and position of
a touch inside the display region.
• The user can touch the screen either by his finger or by using a stylus.
• These displays can be connected to computers, laptops, PDAs, cell phones etc.
Optical devices:
• Optical devices, also known as data-scanning devices, use light as a source of input
for detecting or recognizing different objects such as characters, marks, codes, and
images.
• These devices convert these objects into digital data and send it to the computer for
further processing.
• Some optical devices that are discussed include barcode readers, image scanners,
optical character recognition (OCR) devices, optical mark readers (OMR), and magnetic
ink character recognition (MICR) devices.
Barcode readers:
• A barcode reader (or price scanner or point-of-sale scanner) is a hand-held input
device which is used to capture and read information stored in a barcode.
• A barcode reader consists of a scanner, a decoder, and a cable used to connect the
reader with a computer.
• The barcode reader merely captures and translates the barcode into numbers
and/or letters.
• To make use of the information captured it must be connected to a computer for
further processing.
• For this purpose, the barcode reader is connected to a computer through a serial
port, keyboard port, or an interface device called a wedge.
Advantages: Cheap, Portable, Used to read data stored in bar codes, Handy and easy to
use
Image scanner:
• It is a device that captures images, printed text, handwriting from different sources
and converts it into a digital image for computer editing and display.
Advantages:
• Printed documents can be converted into text files
• Advanced OCR can recognize handwritten text and convert them into computer
readable text files
Disadvantages:
• OCR cannot recognize all types of fonts
• Documents that are poorly types or have strikeover cannot be recognized
• Very old documents when passed through OCR may not have an exact copy of the
text file.
OPTICAL MARK RECOGNITION
• OMR is the process of electronically extracting data from marked fields, such as
checkboxes and fill-infields, on printed forms.
• The optical mark reader is fed with an OMR sheet to detect the presence of a mark
by measuring reflected light levels.
• The OM reader interprets this pattern marks and spaces and stores the interpreted
data in computer for storage, analysis and reporting.
• The error rate for OMR technology is less than 1%.
• It is used for applications in which large numbers of hand-filled forms have to be
quickly processed with great accuracy, such as surveys, reply cards, questionnaires,
ballots or sheets for multiple choice questions.
Advantages:
• Optical mark readers works with a very fast speed. They can read up to 9,000 forms
per hour
• They are accurate machines with error rates of just 1%
Disadvantages:
• Difficult to gather large amount of information.
• Some data may be missing in the scanned documents.
• It is a sensitive device that rejects the OMR sheet if it is folded, torn or crushed.
MAGNETIC INK CHARACTER READER (MICR)
• MICR is used to verify the legitimacy or originality of paper documents, especially
checks.
• MICR consists of magnetic ink printed characters which can be recognized by high
speed magnetic recognition devices .
• The printed characters provides important information (like check number, bank
routing number, checking account number and in some cases the amount of the check)
for processing to the receiving party.
• MICR is widely used to enhance security, speed up the
• sorting of documents and minimize the exposure to check fraud.
Audiovisual Input devices:
• Audio devices.
• Video Input devices
Audio devices
• Audio devices are used to either capture or create sound. They enable computers to
accept music, speech or sound affects for recording and/or editing.
• Microphone and CD player are examples of two widely used audio input devices.
• Microphone feeds audio input to the computer. The computer must have a sound
card to convert analog signals generated through microphone into digital data so that it
can be stored in the computer.
• When the user wants to hear the pre-recorded audio input, the sound card converts
the digital data into analog signals and sends it to the speakers.
Advantages: Audio devices can be used by people who have visual problems; It is best
used in situations where users want to avoid i/p through keyboard or mouse
Disadvantages: Audio input devices are not suitable in noisy places; With audio input
devices it is difficult to clearly distinguish between two similar sounding words like “sea”
and “see”
Video Input Devices
• Video input devices are used to capture video from the outside world into the
computer.
• Digital camera is used to capture images or videos. It digitizes the image or video and
stores them on a memory card.
• The data can then be transferred to the computer using a cable which connects
computer to the digital camera.
• Web cameras also capture videos which can be transferred via internet in real time.
Advantages:
• Video input devices are very useful for applications like video conferencing
• Video input devices can be used to record memorable moments in one’s life
• Video input devices can be used to check security
Disadvantages:
• Videos and images captured using video input devices have a very big file size and
there must be compressed before being stored on the computer.
OUTPUT DEVICES
• Any device that outputs/gives information from a computer is called an output
device.
• Output devices are electromechanical devices which accept digital data from the
computer and convert them into human understandable language.
• This screen is coated with phosphor, which glows when struck by the beam, thereby
displaying the picture which the user sees on the monitor.
Advantages:
• The images are clear even when we try to view in different angle.
Disadvantages:
• They are bigger in size and weight and therefore difficult to move from one place to
another when compared with other types of monitor.
• LCD monitor is a thin, flat electronic visual display that uses the light modulating
properties of liquid crystals which do not emit light directly.
• LCD screens are used in a wide range of applications ranging from computer
monitors, television, instrument panels, aircraft cockpit displays, signage, to consumer
devices like such as video players, gaming devices, clocks, watches, calculators, and
telephones.
• The LCD consists of two pieces of polarizing filters (or substrates) that contain a
liquid crystal material between them.
• A backlight creates light which is made to pass through the first substrate.
• Simultaneously, the electrical currents cause the liquid crystal molecules to align to
allow varying levels of light to pass through to the second substrate and create the
colors and images are seen on the screen.
• Most LCD displays use active matrix technology in which a thin film transistor(TFT)
arranges tiny transistors and capacitors in a matrix of the display.
• Passive matrix technology is the other type of LCD, which uses a grid of conductive
metal to charge each pixel.
Advantages:
• They are very compact and light weight, consume less power.
• They are more reliable than CRTs and can be made in almost any size or shape.
Disadvantages:
• Images are not very clear when tried to view from an angle.
PLASMA MONITORS
• Plasma monitors are thin and flat monitors widely used in TVs and computers. The
plasma display contains two glass plates that have tiny cells filled with xenon and neon
gas.
• To ionize the gas in a particular cell, the electrodes that intersect at that cell are
charged at least thousands of times in a small fraction of a second
• The current creates a rapid flow of charged particles thereby stimulating the gas
atoms to release ultraviolet photons.
• When these UV photons hit a phosphor atom in the cell, one of the phosphor's
electrons jumps to a higher energy level and the atom heats up. When the electron falls
back to its normal level, it releases energy in the form of a visible light photon.
Advantages: The technology allows producing a very wide screen using extremely thin
materials, very bright images are formed which look good from every single and are not
heavy and hence portable.
PROJECTOR
• A projector is a device which takes an image from a video source and projects it onto
a screen or other surface.
• These days, projectors are used for a wide range of applications varying from home
theater systems to organizations for projecting information and presentations onto
screens large enough for rooms filled with people to see.
• LCD Projector make use of their own light to display the image on the wall and are
based on LCD technology. Requires darkened room as image may be blurred.
• Digital light processing (DLP) projector use number of mirrors to reflect the light. The
room may be darkened or not as it displays clear image in both the situations.
SPEAKERS
• Today all business and home users demand sound capabilities and thus different
types of speakers to enable users to enjoy music, movie, or a game and the voice will be
spread through the entire room.
• With good quality speakers, the voice will also be audible even to people sitting in
another or room or even to neighbors.
• However, in case the user wants to enjoy loud music without disturbing the people
around him, he can use a headphone.
• Another device called headset was developed to allow the users to talk and listen at
the same time, using the same device.
Hard copy output devices produce a physical form of output. For example, the content of
a file printed on a paper is a form of hard copy output.
Printers:
Printer is a device that outputs text and graphics information obtained from the
computer and prints it on to a paper. Printers are available in the market in a variety of
size, speed, sophistication, and cost. The qualities of printer which are of interest to
users include:
Color: Colored printouts are needed for presentations or maps and other pages where
color is part of the information. They are more expensive.
Memory: Most printers have a small amount of memory that can be expanded by the
user. Having more memory makes enhances the speed of printing
Resolution: The resolution of a printer means the sharpness of text and images on
paper. It is usually expressed in dots per inch (dpi). Even the least inexpensive printer
provides sufficient resolution for most purposes at 600 dpi.
Speed: Speed means number of pages that are printed in one minute. While high speed
printers are a little expensive, the inexpensive printers on the other hand can print only
about 3 to 6 sheets per minute. Color printing is even slower.
Impact Printer:
• Ex., dot-matrix printers, daisywheel printers, and most types of line printer.
Advantages:
• These allow the user to produce carbon copies and are cheap.
Disadvantages:
• A dot matrix printer prints characters and images of all types as a pattern of dots.
• It has a print head (or hammer) that consists of pins representing the character or
image.
• The print head runs back and forth, or in an up and down motion, on the page and
prints by striking an ink-soaked cloth ribbon against the paper, much like the print
mechanism on a typewriter.
Advantages:
• It can produce carbon copies; offers lowest printing cost per page;
• Widely used for bulk printing where quality of the print is not of much importance;
is cheap;
• When the ink is about to finish, the printout gradually fades rather than suddenly
stopping partway through a job
• It can use continuous paper rather than individual sheets, making them useful for
data logging.
Disadvantages:
• It creates a lot of noise when the pins strike the ribbon to the paper.
• The print head of a daisy wheel printer is a circular wheel, about 3 inches in
diameter with arms or spokes. The characters are embossed at the outer end of the
arms.
• To print a character, the wheel is rotated in such a way that the character to be
printed is positioned just in front of the printer ribbon.
• The spoke containing the required character is then hit by a hammer thereby
striking the ribbon to leave an impression on the paper placed behind the ribbon.
Movement of all these parts is controlled by microprocessor in the printer.
• The key benefit of using a daisy wheel printer is that the print quality is high as the
exact shape of the character hits the ribbon to leave and impression on paper.
LINE PRINTER:
Line printer is a high speed impact printer in which one typed line is printed at a time.
The speed of a line printer usually varies from 600 to 1200 lines-per-minute or
approximately 10 to 20 pages per minute. They are widely used in datacenters and in
industrial environments. Band printer is a commonly used variant of line printers.
Band Printer: A band printer (loop printer) is an impact printer . The set of characters
are permanently embossed on the band and this set cannot be changed unless the band
is replaced. The band itself revolves around hammers that push the paper against the
ribbon, allowing the desired character to be produced on the paper. However, band
printers cannot be used for any graphics printing as the characters are predetermined
and cannot be changed unless the band is changed.
Band printer
• Non-impact printers are much quieter than impact printers as their printing heads
do not strike the paper.
• They offer better print quality, faster printing and the ability to create prints that
contain sophisticated graphics.
• Non-impact printers use either solid or liquid cartridge-based ink which is either
sprayed, dripped or electro statically drawn onto the page. The main types of non-impact
printer are: inkjet, printer, laser printer and thermal printer.
Advantages:
• These produce prints of good quality and hence render sophisticated graphics.
• They are noiseless, fast and can print text in different fonts.
Disadvantages:
INKJET PRINTERS:
• In inkjet printers , the print head has several tiny nozzles, also called jets.
• As the paper moves past the print head, the nozzles spray ink onto it, forming the
characters and images.
• The dots are extremely small (usually between 50 and 60 microns in diameter) and
are positioned very precisely, with resolutions of up to 1440x720 dots per inch (dpi).
• There is usually one black ink cartridge and one so-called color cartridge containing
ink in primary pigments (cyan, magenta, and yellow).
• While inkjet printers are cheaper than laser printers, they are more expensive to
maintain.
• The cartridges of inkjet printers have to be changed more frequently and the special
coated paper required to produce high-quality output is very expensive.
• So the cost per page of inkjet printers becomes ten times more expensive than laser
printers.
• Therefore, inkjet printers are not well-suited for high-volume print jobs.
LASER PRINTER
• It is a non-impact printer that works at a very high speed and produces high quality
text and graphics. It uses the photocopier technology.
• When a document is sent to the printer, the following steps takes place:
1. A laser beam "draws" the document on a drum (which is coated with a photo-
conductive material) using electrical charges.
2. After the drum is charged, it is rolled in toner (a dry powder type of ink).
4. The toner is transferred onto a piece of paper and fused to the paper with heat
and pressure.
5. After the document is printed, the electrical charge is removed from the drum
and the excess toner is collected.
• While color laser printers are also available in the market but users prefer only
monochrome printers because a color laser printer is up to 10 times more expensive
than a monochrome laser printer.
PLOTTERS
• A plotter is used to print vector graphics with a high print quality. They are widely
used to draw maps, in scientific applications and in applications like CAD, CAM and
CAE
• A drum plotter is used to draw graphics on a paper that is wrapped around a drum.
It works by rotating the drum back and forth to produce vertical motion. The pen which
is mounted on a carriage is moved across the width of the paper. Hence, the vertical
movement of the paper and the horizontal movement of the pen create the required
design under the control of the computer.
• In a flatbed plotter, the paper is spread on the flat rectangular surface of the plotter
and the pen is moved over it. Flatbed plotters are less expensive and used in many
smaller computing systems. In this type of plotter, the paper is not moved rather
plotting is done by moving an arm that moves a pen over paper.
PROGRAMMING PARADIGMS
• A programming paradigm is a fundamental style of programming that defines how
the structure and basic elements of a computer program will be built.
• The style of writing programs and the set of capabilities and limitations that a
particular programming language has depends on the programming paradigm it
supports.
Monolithic programming:
Procedural programming:
Advantages
Disadvantages
• No concept of reusability
Structured programming:
• This allows the code to be loaded into memory more efficiently and also be
reused in other programs.
• Modules are coded separately and once a module is written and tested
individually, it is then integrated with other modules to form the overall program.
Advantages
5. New data and functions can be easily added as and when required.
1. Requirement analysis:
• In this phase, user expectations are gathered to know why the software/program
has to be built.
• Then all the gathered requirements are analyzed to frame an objective.
• The last activity in this phase is to document all the requirements to avoid any
further doubts.
• The functionality, capability, performance, and availability of hardware and
software components are analyzed in this phase.
2. Design:
• In this phase, a plan of actions is made before the actual development process
could start.
• This plan will be followed throughout the development process.
• The core structure of the software/program is broken down into modules.
• The solution of the program is then specified for each module in the form of
algorithms, flowcharts, or pseudo codes.
3. Implementation:
• Designed algorithms are converted into program code using any of the high level
languages.
• The choice of language depends on the type of program like whether it is a system
or an application program.
• Program codes are tested by the programmer to ensure their correctness.
Nisha S K, Dept. of ECE, SVIT Page 43
Module-1: Introduction to C
• While constructing the code, the development team checks whether the software is
compatible with the available hardware and other software components that were
mentioned in the Requirements Specification Document created in the first phase.
4. Testing:
• All the modules are tested together to ensure that the overall system works well as
a whole product.
• Although individual pieces of codes are already tested by the programmers in the
implementation phase, there is always a chance for bugs to creep in the program
when the individual modules are integrated to form the overall program structure.
• Software is tested using a large number of varied inputs also known as test data
to ensure that the software is working as expected by the users’ requirements that
were identified in the requirements analysis phase.
6. Maintenance:
• Maintenance and enhancements are ongoing activities which are done to cope
with newly discovered problems or new requirements.
• Such activities may take a long time to complete as the requirement may call for
addition of new code that does not fit the original design or an extra piece of code
required to fix an unforeseen problem.
• As a general rule, if the cost of the maintenance phase exceeds 25% of the prior-
phases cost then it clearly indicates that the overall quality of at least one prior phase
is poor.
• In such cases, it is better to re-build the software (or some modules) before
maintenance cost is out of control.
Algorithms
Decision: Decision statements are used when the outcome of the process depends on
someconditon. For example, if x=y, then print “EQUAL”. Hence, the general form of the if
construct can be given as if condition then process.
Repetition: Repetition, which involves executing one or more steps for a number of times,
can be implemented using constructs such as while, do-while, and for loops. These
loops execute one or more steps until some condition is true.
Flowchart:
Pseudocode:
TYPES OF ERRORS
• These errors if not removed will either give erroneous output or will not let the
compiler to compile the program.
1. Run-time errors:
• Such errors occur when the program performs some illegal operation like
• Run-time errors may terminate program execution, so the code must be written
in such a way that it handles all sorts of unexpected errors rather terminating it
unexpectedly.
Semantic Errors: Semantic errors are those errors which may comply with rules
of the programming language but are not meaningful to the compiler. For
example, if we write, a * b = c; it does not seem correct. Rather, if written like
c=a*b would have been more meaningful.
3. Logical errors:
• Logical Errors are errors in the program code that result in unexpected and
undesirable output which is obviously not correct.
• Such errors are not detected by the compiler, and programmers must check
their code line by line or use a debugger to locate and rectify the errors.
• Logical errors occur due to incorrect statements. For example, if you meant to
perform c= a + b; and by mistake you typed c = a * b; then though this statement
is syntactically correct it is logically wrong.
4. Linker errors:
• Linker Errors occur when the linker is not able to find the function definition
for a given prototype.
• For example, if you write clrscr(); but do not include conio.h then a linker error
will be shown.
Testing Approaches
• Integration Tests are a logical extension of unit tests. In this test, two units
that have already been tested are combined into a component and the interface
between them is tested. This process is repeated until all the modules are tested
together. The main focus of integration testing is to identify errors that occur
when the units are combined.
• System testing checks the entire system. For example, if our program code
consists of three modules then each of the module is tested individually using unit
tests and then system test is applied to test this entire system as one system.
Debugging Approaches
• Once located, errors are then isolated and fixed to produce an error-free code.
It is the least efficient way of debugging a program and is generally done when all
the other methods fail.
Backtracking Method works by locating the first symptom of error and then trace
backward across the entire source code until the real cause of error is detected.
However, the main drawback of this approach is that with increase in number of
source code lines, the possible backward paths become too large to manage.
If some tests indicate that a particular cause maybe responsible for an error then
the data are refined to isolate the error.
Introduction to C
• Today, C has become a popular language and various software programs are
written using this language.
• Many other commonly used programming languages such as C++ and Java
are also based on C.
Characteristics of C
• Small size: C has only 32 keywords. This makes it relatively easy to learn
• Stable language.
• Quick language: Since C programs make use of operators and data types, they
are fast and efficient.
Uses of C
Structure of a C program
• The statements in a C
program are written in a logical
sequence to perform a specific
task.
• Execution of a C program
begins at the main() function
Where, #include refers to the preprocessor statement used for the standard
input/output functions and it starts with the hash (#) symbol.
main( ):- Refers to the function from where the execution of the program begins.
• The source code file contains the source code of the program. The file extension
of any C source code file is “.c”.
• This file contains C source code that defines the main function and maybe
other functions.
• The main() is the starting point of execution when you successfully compile and
run the program.
• A C program in general may include even other source code files (with the file
extension .c).
Header file
• Conventionally, header files names ends with a “.h” extension and its name can
use only letters, digits, dashes, and underscores.
• While some standard header files are available in C, but the programmer may
also create his own user defined header files
Object Files:
• Object files are generated by the compiler as a result of processing the source
code file.
• Linker uses this object file to produce an executable file (.exe file) by combining
the of object files together.
• Object files have a “.o” extension, although some operating systems including
Windows and MS-DOS have a “.obj” extension for the object file.
• The linker links the various object files to produce a binary file that can be
directly executed.
• The object code contains the machine instructions for the CPU, and calls to the
operating system API(Application Programming Interface).
• Therefore, in next step, the object file is processed with another special
program called a linker.
• While there is a different compiler for every individual language, the same
linker is used for object files regardless of the original language in which the new
program was written.
Using Comments
• The compiler ignores the comments when forming the object file. This means
that the comments are non-executable statements.
C tokens
Character set in C
1. English alphabet: Include both lower case (a-z) as well upper case(A-Z) letters.
4. White space characters: These characters are used to print a blank space on
the screen like \b, \t, \v, \r, \f, \n.
5. Escape sequences.
Keywords
• All keywords are basically a sequence of characters that have a fixed meaning.
• The keywords are for, while, do-while, auto break, case, char, continue, do,
double, else, enum, extern, float, goto, if, int, long, register, return, short, signed,
sizeof, static, struct, switch, typedef, union, unsigned, void, volatile
Keywords in C
Identifiers
• Identifiers are names given to program elements such as variables, arrays and
functions.
4. The names are case sensitive. So, example, “FIRST” is different from “first” and
“First”.
It can be of any reasonable length. Though it should not contain more than 31
characters.
DATA SIZE IN
Data type RANGE Use
TYPE
BYTES
3.4E-4932 to
Valueless void 10 -
1.1E+4932
SIZE IN
DATA TYPE RANGE
BYTES
Variables
• When using a variable, we actually refer to address of the memory where the data is
stored. C language supports two basic kinds of variables.
• Numeric variables can be used to store either integer values or floating point values.
• While an integer value is a whole numbers without a fraction part or decimal point, a
floating point number, can have a decimal point in them.
• Numeric values may also be associated with modifiers like short, long, signed and
unsigned.
• Character variables can include any letter from the alphabet or from the ASCII chart
and numbers 0 – 9 that are put between single quotes.
Declaring Variables
• To declare a variable specify data type of the variable followed by its name.
• Variable names should always be meaningful and must reflect the purpose of their
usage in the program.
int emp_num;
float salary;
char grade;
double balance_amount;
Initializing Variables
1. We can assign an initial value to a variable within the declaration part itself called
static initialization.
2. We can assign an initial value to a variable during the program execution called
dynamic initialization.
scanf(“%d”, &a);
Constants
• Constants are used to define fixed values like PI or the charge on an electron so that
their value does not get changed in the program even by mistake.
1.Integer constants
2.Floating-point constants
3.Character constants
4.String constants
To declare a constant, precede the normal variable declaration with const keyword and
assign it a value. For example,
• #define PI 3.14159
Declaring Constants
Rule 1: Constant names are usually written in capital letters to visually distinguish
them from other variable names which are normally written in lower case characters.
Note that this is just a convention and not a rule.
Rule 2: No blank spaces are permitted in between the # symbol and define keyword
Rule 3: Blank space must be used between #define and constant name and between
Input/Output statements in C
Streams:
• A stream acts in two ways. It is the source of data as well as the destination of data.
• Streams are associated with a physical device such as the monitor or with a file
stored on the secondary memory.
• In a text stream, sequence of characters is divided into lines with each line being
terminated with a new-line character (\n). On the other hand, a binary stream contains
data values using their memory representation.
• Although, we can do input/output from the keyboard/monitor or from any file but
here we will assume that the source of data is the keyboard and destination of the data
is the monitor.
Formatting Input/output:
• printf is used to convert data stored in the program into a text stream for output to
monitor.
• scanf is used to convert the text stream coming from the keyboard to data values and
printf():
• The printf() function is used to display information required to the user and also
prints the values and variables.
• The syntax can be given as printf(“Control string”, variable list);
• The prototype of the control string is given by
%[flags][width][.precision][modifier]type
Flags are an optional argument which specifies output justification such as numerical
sign, trailing zeros or octal, decimal, or hexadecimal prefixes.
Example:
%6.3f means print floating point value of max 6 digits where 3 digits are allotted for the
digits after the decimal point.
printf(“\n Result: %6.3f”, 123.53435);
output: Result: 123.534
Some examples of printf:
• printf(“\n Result: %d%c%f”,12,'a',2.3);
Output:
the number is
• printf(“\n%7.4f\n%7.2f\n%-7.2f\n%f\n%10.2e\n%11.4e\n%-
10.2e\n%e”,98.7654, 98.7654, 98.7654, 98.7654, 98.7654, 98.7654, 98.7654,
98.7654);
Output:
98.7654
98.77
98.77
98.765400
9.88e+01
9.8765e+01
9.88e+01
9.876540e+01
scanf():
• The scanf() function is used to read formatted data from the keyboard.
*****End*****