0% found this document useful (0 votes)
16 views19 pages

Coa Lab - 2023

The document outlines the identification, assembly, and disassembly of PC components, detailing essential parts such as the motherboard, processor, and power supply. It also includes troubleshooting steps for various hardware issues related to printers and CPUs, emphasizing safe repair practices and necessary tools. Additionally, it describes the functionality of a switched mode power supply (SMPS) and its components.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views19 pages

Coa Lab - 2023

The document outlines the identification, assembly, and disassembly of PC components, detailing essential parts such as the motherboard, processor, and power supply. It also includes troubleshooting steps for various hardware issues related to printers and CPUs, emphasizing safe repair practices and necessary tools. Additionally, it describes the functionality of a switched mode power supply (SMPS) and its components.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

EXPERIMENT-1 : a ) Identification of different components of a PC.

(b) Assembling & disassembling of a PC.

System Components
A modern PC is both simple and complicated. It is simple in the sense that over the years, many of the components
used to construct a system have become integrated with other components into fewer and fewer actual parts. It is
complicated in the sense that each part in a modern system performs many more functions than did the same types of
parts in older systems.

This section briefly examines all the components and peripherals in a modern PC system. Each item is discussed further
in later chapters.

Here are the components and peripherals necessary to assemble a basic modern PC system:

• Motherboard
• Processor
• Memory (RAM)
• Case/chassis
• Power supply
• Floppy drive
• Hard disk
• CD-ROM, CD-RW, or DVD-ROM drive
• Keyboard
• Mouse
• Video card
• Monitor (display)
• Sound card
• Speakers
• Modem

A breakdown of these items is shown in Table

Table Basic PC Components

Component Description

Motherboard The motherboard is the core of the system. It really is the PC; everything else is connected
to it, and it controls everything in the system. Microprocessors are covered in detail in
Chapter 3, "Microprocessor Types and Specifications."

Processor The processor is often thought of as the "engine" of the computer. It's also called the CPU
(central processing unit).

Memory (RAM) The system memory is often called RAM (for random access memory). This is the primary
memory, which holds all the programs and data the processor is using at a given time.
Memory is covered in detail in Chapter 6, "Memory."

Case/chassis The case is the frame or chassis that houses the motherboard, power supply, disk drives,
adapter cards, and any other physical components in the system. The case is covered in
detail in Chapter 21, "Power Supply and Chassis/Case."
Power supply The power supply is what feeds electrical power to every single part in the PC. The power
supply is covered in detail in Chapter 21.

Floppy drive The floppy drive is a simple, inexpensive, low-capacity, removable-media, magnetic
storage device.

Hard drive The hard disk is the primary archival storage memory for the system. Hard disk drives are
also covered in detail in Chapter 10, "Hard Disk Storage."

CD-ROM/DVD-ROM CD-ROM (compact disc read-only) and DVD-ROM (digital versatile disc read-only) drives
are relatively high-capacity, removable media, optical drives. These drives are covered in
detail in Chapter 13, "Optical Storage."

Keyboard The keyboard is the primary device on a PC that is used by a human to communicate with
and control a system. Keyboards are covered in detail in Chapter 18, "Input Devices."

Mouse Although many types of pointing devices are on the market today, the first and most
popular device for this purpose is the mouse. The mouse and other pointing devices are
covered in detail in Chapter 18.

Video card The video card controls the information you see on the monitor. Video cards are covered
in detail in Chapter 15, "Video Hardware."

Monitor Monitors are covered in detail in Chapter 15.

Sound card It enables the PC to generate complex sounds. Sound cards and speakers are covered in
detail in Chapter 16, "Audio Hardware."

Modem Most prebuilt PCs ship with a modem (generally an internal modem). Modems and other
Internet-connectivity devices and methods are covered in Chapter 19, "Internet
Connectivity."

(b) Assembling & disassembling of a PC.


Parts of Computer System
The computer system is made up of following external devices:

• CPU Cabinet
• Monitor
• Keyboard
• Mouse
• Printer/scanner [if attached]

Disassembling the computer system


Detach the power cable:

The disassembling of the computer system starts with externally connected device detachment. Make sure the
computer system is turned off, if not then successfully shut down the system and then start detaching the external
devices from the computer system. It includes removing the power cable from electricity switchboard, then remove
the cable from SMPS (switch mode power supply) from the back of the CPU Cabinet. Do not start the disassembling
without detaching the power cable from the computer system. Now remove the remaining external devices like
keyboard, mouse, monitor, printer or scanner from the back of CPU cabinet.

Remove the Cover:

The standard way of removing tower cases used to be to undo the screws on the back of the case, slide the cover back
about an inch and lift it off. The screwdrivers as per the type of screw are required to do the task.

Remove the adapter cards:

Make sure if the card has any cables or wires that might be attached and decide if it would be easier to remove them
before or after you remove the card. Remove the screw if any, that holds the card in place. Grab the card by its edges,
front and back, and gently rock it lengthwise to release it.

Remove the drives:


Removing drives is easier. There can be possibly three types of drives present in your computer system, Hard disk
drive, CD/DVD/Blue-ray drives, floppy disk drives (almost absolute now a day). They usually have a power connector
and a data cable attached from the device to a controller card or a connector on the motherboard. CD/DVD/Blue Ray
drive may have an analog cable connected to the sound card for direct audio output.

The power may be attached using one of two connectors, a Molex connector or a Berg connector for the drive. The
Molex connector may require to be wiggled slightly from side to side and apply gentle pressure outwards. The Berg
connector may just pull out or it may have a small tab which has to be lifted with a screwdriver.

Now Pull data cables off from the drive as well as motherboard connector. The hard disk drive and CD/DVD drives have
two types of data cables. IDE and SATA cables. The IDE cables need better care while being removed as it may cause
the damage to drive connector pins. Gently wiggle the cable sideways and remove it. The SATA cables can be removed
easily by pressing the tab and pulling the connector straight back.

Now remove the screws and slide the drive out the back of the bay.

Remove the memory module:

Memory modules are mounted on the motherboard as the chips that can be damaged by manual force if applied
improperly. Be careful and handle the chip only by the edges. SIMMs and DIMMs are removed in a different way:

• SIMM - gently push back the metal tabs while holding the SIMM chips in the socket. Tilt the SIMM chip away
from the tabs until a 45% angle. It will now lift out of the socket. Put SIMM in a safe place.
• DIMM- There are plastic tabs on the end of the DIMM sockets. Press the tabs down and away from the socket.
The DIMM will lift slightly. Now grab it by the edges and place it safely. Do not let the chips get dust at all.

Remove the power supply:


The power supply is attached into tower cabinet at the top back end of the tower. Make sure the power connector is
detached from the switchboard. Start removing the power connector connected to motherboard including CPU fan
power connector, cabinet fan, the front panel of cabinet power buttons and all the remaining drives if not detached
yet.

Now remove the screws of SMPS from the back of the cabinet and the SMPS can be detached from the tower cabinet.

Remove the motherboard:


Before removing all the connectors from the motherboard, make sure u memorize the connectors for assembling the
computer if required, as that may require connecting the connectors at its place. Remove the screws from the back of
the motherboard and you will be able to detach it from the cabinet. Now remove the CPU fan from the motherboard.
The heat sink will be visible now which can be removed by the pulling the tab upward. Finally, the processor is visible
now, which can be removed by the plastic tab which can be pulled back one stretching it side way.

Assembling the computer system


The assembling of the computer system is exactly the opposite of disassembling operation. Before starting assembling
the computer system, make sure you have the screws and a screwdriver for those.

The first step for assembling the computer system starts with mounting the processor on the processor socket of the
motherboard. To mount the process, you don't need to apply any force. The special ZIF (zero insertion force) sockets
are usually used to prevent any damage to the processor pins. Once the processor is mounted, the heat sink will be
attached on top of the processor. The CPU fan is also attached on top of the heat sink.

Now the motherboard is to be fixed vertically in the tower case and the screws are fixed from behind of the
motherboard.

Now line up the power supply at the top back end of the cabinet and screw it. The power connectors for motherboard
power supply and CPU fan power supply are to be connected. If the cabinet cooling FAN is required then it is to be
screwed at the back end grill of the cabinet and its power connector is to be connected from SMPS.

Install the CD/DVD drives at the top front end of the cabinet and screw it. Install the Hard disk drive and floppy disk
drive below CD/DVD drive and screw it. Make sure once screwed there is no vibration in either of the CD/DVD, Hard
disk or Floppy disk drives.

Now select the appropriate data cable and connect one end of the cable to its drive socket and another end at its
appropriate connector on the motherboard. For SATA hard disk drive or CD/DVD drives use SATA cable and its power
cable, else use IDE data cable. Do the proper jumper settings as per the usage requirement.

It is time now to mount the memory modules on the motherboard by aligning the RAM to its socket on the
motherboard and press it downward. Make sure the side tab are fixed into the RAM notch. If not, you may still have to
press a bit.

Install the internal cards to its socket and attach the cables or power cable to it. The selection of right socket or slot is
required as per the type of socket.

Cover the tower by placing it and pressing towards front side and screw it.

Connect the external devices with CPU at its appropriate socket. It includes mouse and keyboard at PS2 or USB
connectors. Monitor at the video output socket. Connect the power cable to the back of tower in SMPS. Plug in the
power cable to the electric board

EXPERIMENT-2: Study of different troubleshooting of a dot matrix printer using LX 1050+ Printer Trainer Module.

Problem 1: Printer Does not work

solution: 1.Check the AC supply,check the fuse if a problem in fuse replace it

2.If the power light is ON,check the ON-LINE connections and try again

Problem 2: The printer does not printing during Self test

soluton: 1.check the printer head hardware property

Problem 3: Printer not connected error message displayed

solution: 1.Check the software driver property if the driver will installed properly check the hardware property

2.set dot matrix printer as default printer in printer property

Problem 4: Printer Ribbon cartridge does not move

solution: 1.check the cable from CPU to printer

2.check the stepper motor is working properly or not

3.check the sensor signals from the electronics circuit

Problem 5: Paper Empty Not sensing

solution: 1.check the micro switch by inserting paper manually

Problem 6: Head pin problem and coil check


solution: 1.remove the head and check Ohm vale for each coil firing the pin in the head for open or short connection

2.If the pins are struck due to carbon ink deposits of the ribbon,clean and replace the head

3.If the coil show open circuit,replace the head with new one

EXPERIMENT-3: Study of the functions of SMPS using SMPS Trainer Kit.

SMPS trainer is a very adaptable kit has been designed to explain a veryremarkable and frequently used switching
based power supply-The SMPS (Switched Mode Power Supply).The kit is designed keeping in mind that a student can
comprehend each block of SMPS in a very easy way. Different test points have been provided so that one can observe
the inputs and outputs of each block contained. Being different from aconventional block diagram internal structures
of different blocks are also shown.Switching Transformer and Chopper (The Heart of SMPS) are presented insuch a way
that a student can readily understand their functioning and pin configuration.Since SMPS is different from a traditional
power supplies because it can be used for different voltage inputs (from 80V to 300V AC).If the SMPS has an AC input,
then its first job is to convert the input to DC. This is called rectification. The rectifier circuit can be configured as a
voltage doubler by the addition of a switch operated either manually or automatically. This is a feature of larger
supplies to permit operation from nominally 120volt or 240volt supplies. The rectifier produces an unregulated DC
voltage which is then sent to a large filter capacitor. The current drawn from the Mains supply by this rectifier circuit
occurs in short pulses around the AC voltage peaks. These pulses have significant high frequency energy which reduces
the power factor. Special control techniques can be employed by the following SMPS to force the average input current
to follow the sinusoidal shape of the AC input voltage thus the designer should try correcting the power factor. A SMPS
with a DC input does not require this stage. A SMPS designed for AC input can often be run from a DC supply, as the DC
passes through the rectifier stage unchanged.

EXPERIMENT-4 : Study of different troubleshooting of CPU using CPU Trainer Module.

1.1. Fixing Hardware Problems

1.1.1. Tools and Safe Repair Practices

What tools will a computer lab manager need to perform basic hardware repair? This will depend on the type
of computers being worked on, and also on what tools are locally available. However, good quality screwdrivers in
different sizes will be on every lab’s equipment list. The majority of the screws encountered in computers are of the
Phillips type (the screw head has an X shape on the top), but flat head and hex head screws may also occur. A
computer lab manager can look and see what types of screws are in use in the lab before making a purchase. Magnetic
tip screwdrivers can be very useful since the screws will stay magnetically attached to the screwdriver while the lab
manager locates the screw hole. However it is very important to avoid touching the tips of magnetic screwdrivers to
RAM or hard drives, since the magnetic storage on those devices could be damaged. A pair of needle nose pliers may
also be useful to assist when working in narrow spaces.

For cleaning computer parts, a computer lab manager will need some method for blowing dust out of
computer hardware. If an electric blower is available, this is a very good option. Otherwise a hand operated blower
(with a bellows or bladder attached to a narrow outlet) will do. If affordable, a computer lab manager can also
purchase compressed air in aerosol cans. For dusting and cleaning computer and monitor cases, a lint free cloth is
best. Screens (LCD and CRT) can be cleaned with slightly damp cloths or with small amounts of mild cleaning solutions
that have been reported to be safe for computer monitors. If RAM needs to be cleaned, isopropyl alcohol and lint free
swaps can be used.

There are several safety concerns (both for the lab manager and for the computer equipment) that need to be
attended to. They are listed below.

·Working Environment.The computer work room should be clean, well organized and properly lit. Avoid
hazards to the computer (such as dust or moisture) and hazards to the workers (such as electrical
cords that can be tripped over). The lab manager should also consider good organization as a way to
make repair work more efficient. It should be easy for a worker to return to a project without any
difficulty finding the parts involved.

·Static Electricity.Static electricity discharges (sparks) can be significantly damaging to computer

equipment such as RAM, CPUs and motherboards. Therefore it is important for the computer lab
manager to ground him or herself before working with computer equipment. The tip box here gives
some suggestions. If electrostatic mats or grounding wrist straps are available locally, these items can
also be used to prevent electrostatic shocks.

·Electrical Shock.Before opening up the case of a computer or any other electronic device or cleaning it
with any fluid, make sure that it is unplugged. Otherwise, electricity can be transmitted through the
electronic device and into the worker’s body. This can cause severe injury or even death. Laptop
batteries should also be removed before performing any laptop computer repairs. It is best to avoid
attempting repairs on computer monitors, particularly CRT monitors due to a risk of a dangerous
electrical discharge.

1.1.2.Hardware Repair Planning and Strategy

Before beginning a computer hardware repair, it is important to make sure that the repair is necessary and
that a repair plan is in place. To determine if a repair is necessary, the lab manager should have worked through the
troubleshooting steps described earlier in this module. If a computer is still operational, the lab manager should be
using software tools to diagnose (and in some cases repair) problems before physically opening the computer. For
example, the Device Manager (described in ) can be used to check for hardware faults, and a hard drive diagnostic tool
(such as Chkdsk, described in ) can be used to determine if a hard drive needs to be replaced. Also remember that
error messages can give important information about what is wrong with a computer.

When developing a repair plan, the computer lab manager needs to know which parts are going to be
replaced and how to find and remove those parts from the computer. It is also important to have replacement parts on
hand that are known to be in good condition.

Part re-seating and part swapping are both good strategies to keep in mind when repairing computers. Re-
seating means removing or disconnecting a part, cleaning it if appropriate, and correctly replacing the part. Sometimes
a computer part can function poorly just because a connection is loose or dirty, and re-seating will improve its
performance. If this does not solve a problem, a good next step is to try to swap the same part with one from a
functioning computer. This can be a useful part of troubleshooting, since it helps the lab manager identify whether or
not that part truly is the source of a computer problem, before a purchase is made. People who are just learning about
computer repair can easily practice this with peripheral devices. If a desktop computer keyboard appears not to be
working, for example, try replacing it with a keyboard that is known to work properly.

1.1.3.Basic Hardware Repairs

Below are descriptions of some of the most common hardware repairs, including key steps in the process. In
all cases, however, the lab manager who is just beginning to work on computer repair would be encouraged to
complete these repairs alongside a more experienced technician as they gain skill and confidence. If the lab manager
has an opportunity (through this course or any other) to attend a hardware repair training session, he or she should
insist on being involved in as much hands-on training as is possible.

Replacing a Power Supply. For desktop computers in developing countries, power supply failure is a common
problem. This is due to an uneven or “dirty” voltage and power surges. Before replacing a power supply, a lab manager
should make sure that it truly is dead by following the tip box in The follow the steps below:

1.Unplug the power cord from the back of the computer case.

2.Open up the computer case. The method varies with the brand and model of computer, but often
involves laying the case on its side and opening up the side panel. Some computer cases use screws
and others have buttons to press that release one side panel.

3.Find and unscrew all of


the screws attaching
the power supply to
the back of the case.
Usually there will be
four screws, located
just outside the cut out
in the case (or along
the mesh grid) where
the power supply is
found. Do not
disconnect the various
cables yet. Move the
dead power supply as
far out of the way as
the cables will allow.
You may be able to set the power supply on top of the case (see photo).
4.Install the new power supply and screw in all screws.

5.One by one, detach the cables from the old power supply to the various computer components, and
replace them with the cables from the new power supply. Doing this one by one will help make sure
that no components are missed. There will be power supply connectors for the motherboard and all
drives. When removing the cables, keep an eye out for latches that need to be depressed to release
the connector. All of the connectors should only fit in one direction, and with little force. If a
connector does not attach easily, make sure that it is properly aligned before pushing harder.

Replacing a Hard Drive.Replacing a faulty hard drive is not a difficult task, but a lab manager should have
done some investigative work first to determine if the hard drive is faulty. This could include running the Chkdsk utility,
as described in listening for unusual noises coming from the hard drive and also checking to make sure the cables to
the hard drive are still fully connected. The computer may also present error codes during start up that indicate a
problem with the hard drive. Before replacing a hard drive, it is worth trying to reset the BIOS to the default settings to
see if this fixes the problem. To do this, enter the BIOS during computer start up (as described in ) and choose the
default settings. Then save the new settings and exit. The onscreen instructions in the BIOS program will guide the
computer lab manager through these steps.

Once it has been determined that a hard drive problem is likely, the computer lab manager should follow the
steps below to replace the hard drive with a known working hard drive.

1.Disconnect the computer case from electricity and then open the computer case (as described above).

2.Locate the hard drive. It


will likely be found in a
metal case or cage near
the front of the
computer case, below
the other drives. It
could be mounted
directly on the cage or
it could be mounted on
rails that will slide out
of the case (see photo).

3.Unscrew the hard drive


from the cage or slide
the rails out and
unscrew the hard drive
from the rails.

4.Remove the long ribbon cable from hard drive. There may have been a small amount of glue used to
hold the ribbon in place that will also need to be removed. Then remove the smaller power cable. If
it is difficult to remove, gently wiggle the connector back and forth along its long axis as you pull.
Note the orientation of the connector (which end is the red wire on?) to make sure that the new
hard drive is connected in the same manner.

5.If there are two hard drives in a computer, one is called the master and the other the slave. On older
hard drives, an electrical connection needs to be changed to indicate whether the hard drive is a
master or a slave. If the hard drive being installed has not been used before, it will be correctly set as
a master (or also on the acceptable “Cable Select” setting, used when the ribbon cable has two
connectors – one for a master and one for a slave). If the hard drive has been previously used as a
slave, however, it will need to be changed to a master. To do this, look for a diagram on the hard
drive that shows the pattern for connecting (jumping) two of the eight pins located between the two
cable connectors on the front end of the hard drive. Then using needle nose pliers, pull off the
jumper that is connecting two of the pins and replace it to connect the proper pair.

6.Connect the cables to the new hard drive. Then screw the hard drive back on to the rails and slide the
rails into position (or screw the hard drive directly to the cage if there are no rails). Make sure that all
of the other ribbons and cables are as they were found. Close the case and the repair is complete.
Note that if any new noises or problems appear after the installation, it is possible that another
device or cable was disrupted during the repair and needs to be reattached or reseated.

Replacing a Hard Drive for a Laptop Computer.Hard drives for many laptop computers can be replaced quite
easily because the manufacturers have made the hard drives accessible from hatches on the underside of the
computer. To replace the hard drive on a laptop with an accessible hard drive follow the steps below:

1.Remove the laptop battery before making this (or any other) laptop repair. This is important in order to
avoid electricity from
the battery flowing
through the computer
during repair, which
could be damaging to
computer components.
The technique for
removing the battery
depends on the make
and model of the
laptop, but often
involves unlocking the
battery at one or two
points (on the
underside of the
computer) and then
sliding it out.

2.With the laptop resting upside down on a table, find the hard drive compartment and unscrew the
screw or screws holding the lid in place. Remove the lid and examine how the hard drive is attached
to the computer. Most likely you will see that the hard drive is attached to a cage or brackets that will
slide out with the hard drive (see photo).

3.Slide out the assembly containing the hard drive in its cage or brackets. You may have to push the
assembly in or lift it up first in order to clear anything else used to hold the assembly in place.

4.Remove any screws attaching the laptop to its cage/brackets, remove the damaged hard drive, replace
it with a functioning laptop hard drive and then retighten all screws.

5.Slide the assembly back into the laptop and secure it as it was previously. Make sure that you push hard
enough to reattach the hard drive to the power and data connectors. Push horizontally (or as close as
possible to horizontally) when reconnecting.

6.Close the hard drive compartment and replace all screws. Then replace the laptop battery, turn the
computer over and restart it.

Replacing RAM.As discussed in , a lab manager may want to add RAM to speed up a slow computer. RAM also
can fail or come loose from its housing and need to be reseated. If a lab manager has decided that a computer needs
new or additional RAM, it is important to make sure that the RAM used is compatible with the computer system. There
are several online RAM sales companies that will identify the appropriate RAM if a user inputs the computer make and
model. Two example companies are Corsair (www.corsairmemory. and Crucial (www.crucial.com). Once the RAM has
been obtained, the lab manager should follow the steps below to replace the RAM. Please Note: RAM is very easily
damaged by electrostatic charges, so it is very important for the user to be grounded before picking up RAM. Also RAM
should only be handled by the edges.

1.Open the computer case as previously described. Find the RAM slots (long parallel connectors). Note
which slots are occupied and if
the slots are numbered (at the
ends). If the slots are not
numbered, the slots closest to
the processor are probably the
lower numbered slots and
should be filled first.

2.Simultaneously push down and


out on both retaining clips (on
each end) of a RAM slot to
remove the old RAM. Note the
orientation of the RAM so that
the replacement RAM can be
put in facing the same
direction. There should be
some notches on the bottom edge of the RAM that can be used as a guide.

3.Gently place the new RAM in the socket and press down firmly on the top of the RAM at both ends (see
photo). When the RAM module is correctly seated, the retaining clips will automatically close.

4.Close the computer case as previously described.

Replacing Laptop RAM.Laptop computers have a compartment on the back side designed for accessing RAM.
When the screws for this compartment are removed (but don’t forget to remove the laptop battery first for safety
reasons!), the RAM should be visible. For some laptops, however, only the slot for expansion (extra) RAM is visible. In
these cases the rest of the RAM is can be accessed by removing the keyboard, a more difficult task (discussed below).
Laptop RAM rests horizontally, with the slot on one end. To install RAM, hold the RAM by its edges, and bring it up
towards its slot at about a 30 degree angle (see photo). Then gently push the RAM in while flattening out the angle.

Other Laptop Repairs. It is possible to replace


the keyboard, individual keys or the screen on a laptop
with only a moderate amount of difficulty. The
challenge, however, is that every different model of
laptop requires a different method for accessing and
removing these parts. Either a lab manager should
watch other people do these repairs and learn from
them, or find information on the Internet for the
specific desired repair. Specific searches should result
in detailed diagrams, descriptions or videos. For
example, if someone wanted to replace a key on a Dell
laptop, the search terms “replacing laptop keys Dell”
will yield useful results. Similarly, if someone wanted
to replace the entire keyboard on a Toshiba laptop, the
search terms “replacing laptop keyboard Toshiba” will
suffice. In general when performing laptop repairs, the computer lab manager should remember these guiding
principles:

1. Always remove the battery first for safety reasons.

2. Keep note of what screws are removed and in what order. Also keep track of the actual screws!

3. When taking a laptop apart, be slow and mindful of the process. This will make it easier to put the
computer back together afterwards. For complicated repairs, consider keeping notes
of the steps performed

EXPERIMENT-9 :Write a C/C++ program to perform signed bit multiplication using Booth’s

algorithm.

#include <stdio.h>

#include <math.h>

int a = 0,b = 0, c = 0, a1 = 0, b1 = 0, com[5] = { 1, 0, 0, 0, 0};

int anum[5] = {0}, anumcp[5] = {0}, bnum[5] = {0};

int acomp[5] = {0}, bcomp[5] = {0}, pro[5] = {0}, res[5] = {0};

void binary(){

a1 = fabs(a);

b1 = fabs(b);

int r, r2, i, temp;

for (i = 0; i < 5; i++){

r = a1 % 2;

a1 = a1 / 2;

r2 = b1 % 2;

b1 = b1 / 2;

anum[i] = r;

anumcp[i] = r;

bnum[i] = r2;

if(r2 == 0){

bcomp[i] = 1;

if(r == 0){

acomp[i] =1;

//part for two's complementing


c = 0;

for ( i = 0; i < 5; i++){

res[i] = com[i]+ bcomp[i] + c;

if(res[i] >= 2){

c = 1;

else

c = 0;

res[i] = res[i] % 2;

for (i = 4; i >= 0; i--){

bcomp[i] = res[i];

//in case of negative inputs

if (a < 0){

c = 0;

for (i = 4; i >= 0; i--){

res[i] = 0;

for ( i = 0; i < 5; i++){

res[i] = com[i] + acomp[i] + c;

if (res[i] >= 2){

c = 1;

else

c = 0;

res[i] = res[i]%2;

for (i = 4; i >= 0; i--){

anum[i] = res[i];

anumcp[i] = res[i];

}
if(b < 0){

for (i = 0; i < 5; i++){

temp = bnum[i];

bnum[i] = bcomp[i];

bcomp[i] = temp;

void add(int num[]){

int i;

c = 0;

for ( i = 0; i < 5; i++){

res[i] = pro[i] + num[i] + c;

if (res[i] >= 2){

c = 1;

else{

c = 0;

res[i] = res[i]%2;

for (i = 4; i >= 0; i--){

pro[i] = res[i];

printf("%d",pro[i]);

printf(":");

for (i = 4; i >= 0; i--){

printf("%d", anumcp[i]);

void arshift(){//for arithmetic shift right

int temp = pro[4], temp2 = pro[0], i;

for (i = 1; i < 5 ; i++){//shift the MSB of product


pro[i-1] = pro[i];

pro[4] = temp;

for (i = 1; i < 5 ; i++){//shift the LSB of product

anumcp[i-1] = anumcp[i];

anumcp[4] = temp2;

printf("\nAR-SHIFT: ");//display together

for (i = 4; i >= 0; i--){

printf("%d",pro[i]);

printf(":");

for(i = 4; i >= 0; i--){

printf("%d", anumcp[i]);

int main(){

int i, q = 0;

printf("\t\tBOOTH'S MULTIPLICATION ALGORITHM");

printf("\nEnter two numbers to multiply: ");

printf("\nBoth must be less than 16");

//simulating for two numbers each below 16

do{

printf("\nEnter A: ");

scanf("%d",&a);

printf("Enter B: ");

scanf("%d", &b);

}while(a >=16 || b >=16);

printf("\nExpected product = %d", a * b);

binary();

printf("\n\nBinary Equivalents are: ");

printf("\nA = ");
for (i = 4; i >= 0; i--){

printf("%d", anum[i]);

printf("\nB = ");

for (i = 4; i >= 0; i--){

printf("%d", bnum[i]);

printf("\nB'+ 1 = ");

for (i = 4; i >= 0; i--){

printf("%d", bcomp[i]);

printf("\n\n");

for (i = 0;i < 5; i++){

if (anum[i] == q){//just shift for 00 or 11

printf("\n-->");

arshift();

q = anum[i];

else if(anum[i] == 1 && q == 0){//subtract and shift for 10

printf("\n-->");

printf("\nSUB B: ");

add(bcomp);//add two's complement to implement subtraction

arshift();

q = anum[i];

else{//add ans shift for 01

printf("\n-->");

printf("\nADD B: ");

add(bnum);

arshift();

q = anum[i];

}
printf("\nProduct is = ");

for (i = 4; i >= 0; i--){

printf("%d", pro[i]);

for (i = 4; i >= 0; i--){

printf("%d", anumcp[i]);

OUT PUT:

BOOTH'S MULTIPLICATION ALGORITHM

Enter two numbers to multiply:

Both must be less than 16

Enter A: 12

Enter B: 12

Expected product = 144

Binary Equivalents are:

A = 01100

B = 01100

B'+ 1 = 10100

-->

AR-SHIFT: 00000:00110

-->

AR-SHIFT: 00000:00011

-->

SUB B: 10100:00011

AR-SHIFT: 11010:00001

-->

AR-SHIFT: 11101:00000

-->

ADD B: 01001:00000

AR-SHIFT: 00100:10000

Product is = 0010010000

EXPERIMENT-10: Write a C/C++ program for IEEE-754 floating point representation and perform
Addition/Subtraction.
#include <stdio.h>

void printBinary(int n, int i)

// Prints the binary representation

// of a number n up to i-bits.

int k;

for (k = i - 1; k >= 0; k--) {

if ((n >> k) & 1)

printf("1");

else

printf("0");

typedef union {

float f;

struct

// Order is important.

// Here the members of the union data structure

// use the same memory (32 bits).

// The ordering is taken

// from the LSB to the MSB.

unsigned int mantissa : 23;

unsigned int exponent : 8;

unsigned int sign : 1;

} raw;

} myfloat;

// Function to convert real value

// to IEEE foating point representation

void printIEEE(myfloat var)

// Prints the IEEE 754 representation

// of a float value (32 bits)

printf("%d | ", var.raw.sign);


printBinary(var.raw.exponent, 8);

printf(" | ");

printBinary(var.raw.mantissa, 23);

printf("\n");

// Driver Code

int main()

// Instantiate the union

myfloat var;

// Get the real value

var.f = -2.25;

// Get the IEEE floating point representation

printf("IEEE 754 representation of %f is : \n",

var.f);

printIEEE(var);

return 0;

OUTPUT:

IEEE 754 representation of -2.250000 is :

1 | 10000000 | 00100000000000000000000

You might also like