You are on page 1of 112

Computing & Informatics

L-10

Microprocessors Memory Semiconductor Memory

Memory Controller
Magnetic Memory

Optical Disks
PCMCIA cards and slots
1

Computing & Informatics

L-10

Microprocessors
Intel 8085 8 bit microprocessor, implemented in NMOS Technology. 40 Pin LSI chip. 3, 5 and 6 MHZ are employed. 80 basic instructions and 246 opcode. 8 bit data bus and 16 bit address bus. Intel 8086 16 bit microprocessor, implemented in HMOS Technology. 40 Pin LSI chip. 5, 8 and 10 MHZ are employed. 16 bit data bus and 20 bit address bus lines corresponds to 1MB memory. 16 low order address lines are multiplexed with data line and 4 high order address lines are multiplexed with status signal. 2

Computing & Informatics

L-10

Microprocessors
Intel 80386 32 bit microprocessor. 386Sl version developed for laptop computers. Designed to consume low power. 32 bit data bus and 32 bit address bus. Intel 80486 32 bit microprocessor, implemented in CHMOS Technology. It contains 32 bit CPU, a floating point processor, 8 Kb or 16 KB cache. 168 pin grade array or 196-lead plastic quad flat package. Different versions of 486 works between 25 100 MHz clock. Can directly address 4 GB memory.
3

Computing & Informatics

L-10

Microprocessors
Pentium with Multimedia extension (MMX) Operating frequency 200 MHz. Two cache 16 KB each. The MMX pipeline uses intensive parallel processing of data. The Celeron, Pentium II and Pentium III also uses MMX. Pentium IV 32 bit microprocessor and 64 bit on Pentium 4 HT microprocessor. Operating frequency up to2.8 GHz.

Computing & Informatics

Memory

L-10

Essential component of computer, stores data, programs and results. Three kinds of memory in modern computers: Semiconductor Magnetic Optical memories Types of memories Main memory Secondary (Auxiliary) memory
Memory Primary (Main) Memory RAM Memory Auxiliary (Secondary) Memory ROM Memory

Static Memory

Dynamic Memory

Masked ROM

PROM

EROM

EEROM
5

Computing & Informatics

L-10

Memory
The semiconductor memory is employed as main memory or primary memory of the computer. RAM ROM IC are used as the main memory of computer. The magnetic and optical memory are used as secondary memory. Secondary memory is employed for bilk storage or mass storage of programs data and other information. Backup memory is used to store the copy of the important programs such as OS, compliers etc. floppy disk CDs and magnetic disks are used as back up memory. The cache memory is placed in between CPU and the main memory. It is semiconductor memory, and is faster than main memory. Write through and write back cache schemes are used in computers. 6

Computing & Informatics

L-10

Memory
The diagrams shown below represents the memory hierarchies as per the speed of operation.

C P U

Primary Memory

Secondary Memory

C P U

Cache MEM

Primary Memory

Secondary Memory
7

Computing & Informatics

L-10

Semiconductor Memory
Semiconductor are of two types: Random access Memory RAM and Read only memory ROM. The read write memory is commonly called RAM. RAMs RAM is volatile memory, the information exist in the memory till the power is on. Two types of RAM are: Static RAM and Dynamic RAM. Static RAM stores information as long as power is on. In case of Dynamic RAM the the information stored is lost in very short time (few milliseconds). Hence these are to be refreshed periodically. For this purpose RAM controller are used.
8

Computing & Informatics

L-10

Semiconductor Memory
Static RAM uses Flip flops whereas Dynamic RAM uses gates with capacitor so it requires less transistors per memory. Extended Data Output RAM (EDO-RAM): any memory access stores bytes of data into latches. Latches holds next 256 bytes of information. SDRAM (Synchronous DRAM): these RAM chips uses the same clock rate as the CPU, so it remains ready to transfer data when needed by the CPU. DRAM (Dual-Ported RAM: allows to access two memory locations simultaneously, also called video RAM (VRAM or WRAM windows RAM) SIMM & DIMM: single inline & double inline modules are small printed ckt cards on which several DRAM chips are placed. 9

Computing & Informatics

L-10

Semiconductor Memory
ROMs ROM is non-volatile memory, the information exist in the memory even if the the power goes off. Used fro permanent storage of data. They are cheaper as compared to RAM. PROM: programmable ROM. Its content can be decided by the user. The user can store permanent programs using PROM programmer. EPROM: in erasable PROM stored data can be erased by exposing it it to high intensive SW ultraviolet light. EEPROM: electrically erasable PROM can be erased and reprogrammed on board easily on a byte by byte basis. Flash memory: it is EEPROM but uses one transistor per cell. Nonvolatile RAM: high speed RAM & EEPROM are packed in 10 one chip to form non volatile RAM.

Computing & Informatics

L-10

Memory Controller
A dynamic RAM (DRAM) requires refreshing ckt to refresh the content, for this purpose DRAM controllers are evolved. Intel 8203: 64K DRAM controller capable of directly addressing and driving up to 64 devices without external drivers. Provides multiplexed address, address strobes, refresh logic, and refresh / access arbitration. Intel 8207: is dual port DRAM controller. It interfaces 16K, 64K and 256K DRAMs. Can directly address 2 MB without any external drivers. A dual port interface permits two different busses to access memory independently. Intel 82C08: CHMOS DRAM controller. Can interface 64K and 256K DRAMs. Can directly address 1MB. Capable of performing the task of memory refreshing employing battery backup.
11

Computing & Informatics

L-10

Magnetic Memory
It is permanent type memory. It is non-volatile. Used as secondary and backup memory. Data is stored on the magnetic coating film by electrical pulses of suitable polarity to the magnetizing coil of a read /write head. Two techniques: longitude recording (magnetic region is oriented parallel to the disk surface along the track) and Vertical recording ( the magnetic regions are vertical to the disk surface). Types of Magnetic memory: Magnetic Disk (Hard Disks and Floppy Disk and Magnetic Tapes. Magnetic Disk is a surface device. Stores data on its surface. Surfaces is divided into concentric tracks and each track is 12 divided into sectors.

Computing & Informatics

L-10

Magnetic Memory
The number of bytes stored in each sector is same. So all tracks store same number of data. These disks are semi random devices. Track is selected in random fashion but data is written or read in serial fashion. The time required to move the R/W head to the addressed sector is access time (time to move head to the track is seek time + time required to bring the starting position of the sector is latency time). Disk Controller (DC) are required to convert instruction received from software to electrical pulses to operate disk. DC also issue commands to perform R/W operation. Data separation error detection also taken care by DC
13

Computing & Informatics

L-10

Magnetic Memory
Hard Disk: On line storage device connected permanently to computer. Made up of Aluminum. With thin coating of magnetic material over it. Read write head and disks are kept in sealed, air filtered enclosure To increase capacity several hard disks are mounted on common drive to constitute disk pack. RAID Systems: Redundant Arrays of Inexpensive Disks (RAID) system disks operate in parallel and stores the same information. Improves the storage reliability by eliminating the risk of data lost. Large files is stored in many disks by breaking the file into groups.
14

Computing & Informatics

L-10

Optical Memory
Information is written in the disks using the laser beam. Provides the larger capacity. And has longer life. Slow access time of the drive. No chance of head crash, since head does not touch disk. Three types CD ROM (prerecorded data can be read out) WROM ( write once and read many times) Erasable optical Disk (write many and read many times) Now DVD (Digital Versatile Disks) are also coming which has more capacity to store data than a CD. It contains more layers.
15

Computing & Informatics

L-10

PCMCIA Cards and Slots


PCMIA stands for Personal Computer Memory Card International Association. These are smart cards becoming standard feature for desktop and portable machines. PCMCIA slots (socket) are designed to fit into floppy drive mounting bays. These slots can be used for exchanging data using PCMCIA cards. Type-I type has 34 pin connector 3.3 mm thick, whereas type-II cards are 5 m thick and have 68 pins and type-III cards are 10.5 mm thick and have 68 pin connector. Type-IV has 166mm thick. These cards and slots supports hot insertion.
16

Computing & Informatics

L-11

Input Output Devices Keyboard Mouse

Monitor
Printer

Other I/O devices


Software
17

Computing & Informatics

L-11

Input and Output Devices


The input/ output devices (I/O) and secondary storage units of computer are called peripherals. Data and instruction are entered through input devices. An input device converts input data and instruction into suitable binary form which can be accepted by the computer. Some input devices are Keyboard, Mouse, light pen, joy stick, track ball, touch screen, graphic tablet etc. The out put devices receive information from the computer and provide them to user. The computer sends information to O/p device in binary form. The O/p device converts into a form which is used by by user, Some O/p devices are Monitor, Printer, speakers, LCD display 18 etc.

Computing & Informatics

L-11

Keyboard
Programs and data are entered into a computer through Keyboard. It is similar to a typewriter. It contains alphabets, digits, special characters and some control Keys. When a key is pressed a signal is produced which is detected by keyboard encoder and encoder sends a binary code to the computer. The binary code may be an ASCII EBCDIC or Hex code. The binary code send by encoder is taken from a look up table. Computers use standard keyboards having Qwerty type layout. For faster typing keys are arranged to give a different layout known as Dvorak layout. Construction of keys can be Mechanical Keyswitch, Capacitive 19 Keyswitch or Hall Effect Keyswitch.

Computing & Informatics

L-11

Mouse
A mouse is a pointing device. It is used to select a displayed menu on option on the CRT. It is held in on hand and moved across a flat surface. Movement is detected by the two rotating wheels on the underside of the mouse. The pulses transmitted by the mouse (generated by shaft encoder for every incremental movement of the wheel) determine the the distance moved. The mechanical mouse explained above picks up drift. An Opto-mechanical mouse has been developed. It contains a ball which rolls on two shafts. The shafts turn optical shaft angle encoders to convert motions to electrical signals.
20

Computing & Informatics

Monitor

L-11

A CRT (Cathode Ray Tube ) display unit or monitor is a commonly used out put device. It can display the data information received from computer in alphanumeric character and graphs. Though CRT is basically O/p device but it can perform limited input operations when used in conjunction with light pen. The CRT is similar to TV screen. It is vacuum tube . An electron beam is produced and directed towards the front of the CRT. A coating of phosphor material is made up in the inner side of screen. It emits light when struck by an electron beam. To produce colour display three phosphor red blue and green are used. Three different beams for each colour is produced in such a way that these beams struck the corresponding colour phosphor dot arranged in a special manner. 21

Computing & Informatics

Monitor

L-11

Raster Scan and Vector display methods are used in the CRT to produce the out put. In raster scan method the electron beam is first directed at the top left hand corner and then it is moved along the first horizontal scan line. When it reaches right hand side the beam is turned of and retrace rapidly left side to the starting point of second line and traces the second line in same manner. In the last line scan when beam reaches in the right hand side bottom corner then it goes back to starting point (top left hand). In vector scan (random scan) method deflecting plates are used to deflect the beam left or right and up or down. The beam can be directed to any point on the screen.
22

Computing & Informatics

Monitor

L-11

A character is displayed on the screen by light dots. A matrix of dots is used for this purpose. The size of the dot-matrix may be 5x7, 7x9 or 7x12. Character generator ROM, stores the dot pattern for the each character. The ASCII or EBCDIC codes of the character to be displayed are stored in a display RAM or video RAM. According to the character to be displayed the content of RAM changes. A row counter and a character counter are employed to address the ASCII code of character in the display. A CRT controllers contains the necessary electronic CKT to control CRT display. Several controller ICs like Intel 8275, 8276, 23 822706 etc. are available.

Computing & Informatics

L-11

Printers
Printers are commonly used out put device. These are classified as: Character Printer, Line Printer and Page Printer. The other classification based on the technology on manufacturing are: Impact printer (uses electromechanical mechanism that causes hammers or pins to strike against against a ribbon to print) and Non-impact printer (uses thermal, chemical, electrostatic, laser beam, inkjet technology for printing) A character Printer prints one character of text at time. They are low speed printers. Character to be printed are sent serially to the printer. In a dot matrix impact type character printers a character is printed by printing selected number of dots from a matrix of dots. The line printer prints one line at time. 24

Computing & Informatics

L-11

Printers
An ink jet printers uses dot matrix approach to print text and graphics. Most printers use multiple jets vertically aligned on a cartridge. A solid colour printer use inks which are solid ar room temperature. At the time of printing inks are melted and flow to the reservoirs in the print head. Laser jet printers are page printers in which entire page is processed at a time. They use laser beam to produce an image of the page containing text graphics on a photo sensitive drums. The drum is coated with negatively charged photoconductive material.
25

Computing & Informatics

L-11

Other Input and Output Devices


Light pen A light pen is a pointing device, used to select a displayed menu option on the CRT. It is photosensitive pen like device. It can also be used for graphics work Joystick It is also a pointing device, used to move the curser position on a CRT screen. Its function is similar to that of a mouse. Track pad It is one of the latest pointing device it looks like a small gray window, about inches wide. One merely slides his fingers tip across the window to move the curser.
26

Computing & Informatics

L-11

Other Input and Output Devices


Scanners It is a kind of input device. These are capable of enetring information directly into the computer. Optical scanners The Optical scanners are capable of reading information recorded on paper employing light sources and light sensors. Touch screen Some computers have touch screen which is sensitive to users touch. One can use finger to point the command displayed on the screen. It is popular on laptops

27

Computing & Informatics

L-11

Software
A program is sequence of instruction. A set of programs written for a computer is called software. Software are of two types System software: the software needed to execute the users program is system S/W. It consist of operating system, assembler, complier, interpreter, debugging programs text editors etc. Application software: the programs written for specific operations makes the application software. Programs like sales order, inventory, pay bills are examples of application S/W. A program which is prepared by programmer to solve certain problem is known as Users program. The operating system is collection of programs that controls the 28 overall operation of a computer.

Computing & Informatics

L-11

Software
The software which are helpful to users in developing, writing, debugging and documenting programs are referred as utility programs. There are two types of utility programs file management and program development. The firm ware is used for the S/W stored in read only storage device. These programs are never expected to change. The way of writing the programs in a computer system depends upon the programming language used. Programming language is tool for writing the application program. Language are of two types: Low level Language and High Level Language.
29

Computing & Informatics

L-11

Software
A language in which each statement is directly translated into single machine code is known as Low level language. Examples of low level language are machine level and the assembly languages of various processors. High level languages are written in form which is easy to understand and normally in the English like statement. The instruction written in HL language are called statement. The statement more clearly resembles English and mathematics as compared to mnemonics in assembly language. Machine language: programs written in the form of 0s and 1s is called machine language programs. There is a specific binary code for each instruction. These binary code differs from computer to computer. 30

Computing & Informatics

L-11

Software
Each microprocessor has its own instruction set and corresponding machine codes. To solve the difficulty in writing programs in machine language assembly language have developed. In assembly language the programs are written in alphanumeric symbol code known as mnemonics. The programming in assembly language is easier and fester as compared to machine language programming. Assembler: A program which translate an assembly language program into a machine language program is called assembler. An assembler which runs a computer for which it produces object code (machine code) is called self assembler.
31

Computing & Informatics

L-11

Software

A cross assembler is an assembler that run on a computer other than for which it produces machine codes. One-Pass Assembler: an assembler which reads the assembly language program only once. Two-Pass Assembler: an assembler which reads the assembly language program twice. The computation time of assembly language program is les as compared to High Level Language. Assembly language programs runs faster to produce the desired result as compared to High Level Language. Assembly language programs can not used on any other computer as compared to High Level Language. Assembly language program contains more instruction as 32 compared to High Level Language.

Computing & Informatics

L-11

Software

A complier is a program which translate a high level language into machine language. It is more intelligent than an assembler.it check for all kinds of limits, ranges, errors etc. Its program execution time is more.it has low sped and low efficiency of memory utilization. If a complier runs on computer for which it produces the object code, then it is called self or resident complier. If a complier runs on computer other than that for which it produces the object code, then it is called cross complier. An Interpreter is a program which translates statements of a high level language into machine codes. It translate one statement at a time. 33 A complier is faster than an interpreter.

Computing & Informatics

L-11

Software
Programming language generations First Generation, 1GL: machine languages is known as first generation Language. Second Generation, 2GL: an assembly language is second generation Language. Assembly language is machine oriented. It is very close to the hardware of the CPU. Third Generation, 3GL: High Level Languages are the third generation Language. These are procedure-oriented languages. The programmer must tell what to do as well how to do.Fortran, Pascal, Cobol and C are examples of these languages. Fourth Generation, 4GL: Non-procedural or object oriented languages are the fourth generation Language. In this language programmer has to tell only what to do.Java, C++, ORACLE and 34 SYBASE are example of these languages.

Computing & Informatics

L-12

Operating Systems MS-DOS UNIX

WINDOWS
Utility Programs

35

Computing & Informatics

L-12

Operating System
It is an organized collection of software consisting of procedures for operating a computer and providing an environment for execution of programs. The objective of an OS is to make system convenient to use and utilize computer computer hardware in efficient manner. OS acts as an interface between users and the hardware of a computer system. OS directly controls computer computer system resources. Two ways to interact with OS: System Call: provides the interface between a running program and the OS Operating system Commands: in this method user may interact with OS directly by means of operating system commands.
36

Computing & Informatics

L-12

Operating System
OS may process its tasks serially (sequentially) or concurrently (several task simultaneously. The OS may employ serial processing, batch processing, multi programming or multi tasking. Serial processing: In serial processing all the Datas or programs are processed serially one by one. This result in low utilization of resources. Batch Processing: Jobs with similar requirements are batched together and run through the computer as a group. Batching similar jobs improve utilization of system resources quite a bit. 37

Computing & Informatics

Operating System

L-12

Multi Programming: It allows more than one job (program) to utilize the CPU time at any moment. When OS picks one program and start executing, during execution the program may need some I/O operation to complete. In that time OS will simply switch to some other program instead of sitting idle. This offers a more efficient approach to increase system performance. Multi Tasking: In multi tasking a program is divided onto different independent tasks and this tasks runs on computer as independent programs running on the computer. This improves the computation time as well as the resource 38 utilization.

Computing & Informatics

L-12

Operating System
The operating system can be broadly classified as: Batch Processing Operating systems: Batch operating system allow little or no interaction between users and executing program. Process scheduling, memory management, file management and I/O management are quite simple. Jobs are typically processed in first come first serve basis. The difficulties with this OS is non interacting environment and of line debugging. Multi Programming Operating systems MOS has a significant potential for improving system throughput and resource utilization. Different forms of MOS are multitasking, multiprocess and multi39 user operating system.

Computing & Informatics

Operating System

L-12

Multi Programming Operating systems A running state of program is called process or task. Multi programming supports multiple concurrent process to reside in primary memory simultaneously. Multi tasking operating system allows two or more active process simultaneously. Multi user operating system allows simultaneous access to a computer system through two or more terminals. Multiprogramming implies multiprocessing multi tasking but multiprocess or multi tasking does not imply multiprogramming. Network Operating systems A NOS is a collection of S/w and associated protocols that allows a set of autonomous computers which are interconnected by a network to be used together in a convenient and cost effective 40 manner.

Computing & Informatics

L-12

Operating System
Network Operating systems Each computer has its own OS instead of running part of global system wide operating system. Each user normally works on its own system on same or different environment. User are aware of where each of files are kept and must move file from one system to another with explicit transfer commands. NOS allows users to access the various resources of the network host. Controlling access so that users with proper authorization are allowed to access particular resources. Making the use of remote resource appear to be identical to the use of local program. 41 Providing up-to-the minute N/w documentation on-line.

Computing & Informatics

L-12

Operating System
Distributed Operating systems A DOS operating system is one that looks to its users like an ordinary centralized operating system but runs on the multiple identical CPUs. The key is transparency. This allows programs to run on several processors at the same time, thus requiring more complex processor scheduling algorithms in order to achieve maximum utilization of CPU time. DOS are considered to be more reliable than uniprocessor system. The OS performs even if certain parts of system (H/W) is malfunctioning. Incremental growth is possible on this operating system. Large systems are made by using the small processor, hence 42 provides the price performance advantage over traditional system.

Computing & Informatics

L-12

Operating System Structure


Layered structure approach In layered structure number of layers (levels), each built upon lower level, makes the operating system. The bottom layer is hardware and top layer is user interface. The main advantage of this is modularity which helps in debugging and verification of system easily. The layers are designed in a way that it uses operating and services only if a layer Layer 5 User program below it. A higher layer Layer 4 Buffering for I/O devices need not know how these Layer 3 Device driver operations are implemented.
Layer 2 Layer 1 Layer 0 Memory manager CPU scheduling Hardware
43

Computing & Informatics

L-12

Operating System Structure


Kernel approach Kernel is part of OS which directly makes interface with hardware It provides mechanism for creation and deletion of processes. It provides processor scheduling It provides mechanism for synchronization of processes. It provides mechanism for interprocess communication. Virtual Machine It is a concept which creates an illusion of real machine. It is created by a virtual machine system that makes real machine appear to be several real machine. Client Server Model In this model a user process (client process) sends an request to a server process, which then does the work and send the answer. 44

Computing & Informatics

L-12

MS-DOS
The operating system for PCs are designed as a single user single task operating system. This has two parts BIOS(Basic Input Output System) and DOS (Disk Operating System). The BIOS is stored in ROM and DOS in floppy disks. Booting Process When power is turned on BIOS takes control, it checks for available H/w, then it reads from disk a small portion of OS and loads it into memory. This Boot program the pulls the rest of OS from the disk stored in main memory and completes the booting process. BIOS is responsible for low level services.
45

Computing & Informatics


MS-DOS

L-12

DOS provides many user services like: Directory management which allows user to create search and deletion of directories. Memory and file management for allocation and de-allocation of memory and allow user to create edit write read the files. Command interpreter to interpret commands issued by the user. Executive functions which provides programs to load and execute user program retrieve error codes, correct and rerun the program. Some utility programs for house keeping cores. File management it is one of the most useful services of an OS. File management is supposed to hide all device specific aspects of file manipulation from user and provide them with an adstract of a simple, uniform space of named files. File organization is a simple byte sequence. OS does not impose any 46 structure on file organization.

Computing & Informatics

L-12

UNIX

Unix is multi user OS which facilitates time sharing and was written in C language in 1973. The interface provided to user is simple but yet powerful. The file system used by UNIX is hierarchical which allows efficient implementation and easy use. UNIX considers all files to be a continuous sequence of characters. UNIX treats peripherals devices as if they are files. UNIX supports a scripting language called shell which allows complex jobs to be performed using several built in programs. UNIX assumes on Knowledge of machine architecture from the user. UNIX can support any programming language that has a compiler or an interpreter provided it has an interface that maps user request for OS services to the standard set of requests used by UNIX. 47

Computing & Informatics

L-12

UNIX
Utilities Shell Kernel Hardware
Terminal Drivers

Test Processing

Pipes Type settling Editors

Device Driver Memory manager

Foreground Background

Compiler

USER

Unix to Unix copy UCP

USER

48

Computing & Informatics

L-12

WINDOWS
It is designed for home use. It is a graphical user interface of Microsoft Corporation. The GUI provides picture oriented interface. Windows presents programs, procedure, files, commands etc. as graphical symbols. The different versions of Windows are Windows-3, Windows-3.1, Windows-3.11, Windows-95, Windows-98, Windows-2000 or Windows-Millennium, Windows-NT and Windows-XP. Windows 95 is a mixed 16 bit and 32 bit multitasking OS. Windows 98 is a faster and easy to use OS.it si a 32 bit operating system. The internet online environment is more closely associated with Windows 98 desktop computers.
49

Computing & Informatics

L-12

WINDOWS

Windows 98 provides plug and play facility. It is also a multitasking operating system. Windows-NT is 32 bit multi user OS. It provides multitasking features. It can run on microprocessors of other companies other than Intels. Windows supports TCP/IP/IPX/SPX data link control for mainframes. Windows-NT provides Client server working mode, which is used in networking of computing systems. The Windows XP embedded OS is used in devices such as hand held computers, TV set-top-boxes and automated industrial machines.
50

Computing & Informatics

L-12

Utility Programs

The utility programs are software tools to help programmers in developing, writing, debugging and documenting programs. They cane either file management or program development utilities. File management utilities are part of OS. The program development utilities help user in writing and testing programs. Editor: a program which permits programmer to enter modify and store source program or text. File manager a program which permits to create, copy, update or delete files on the disks. Loader a program that loads machine codes of program into system Memory. Linker a program that links smaller programs to form a single 51 program.

Computing & Informatics

L-13

Programming Languages Types of languages Components of programming languages

Input and output statement


Assignment statement and Print statement

Subroutine and functions


Algorithm and flow-chart
52

Computing & Informatics

L-13

Programming Languages

A program is set of instruction that are arranged in a sequence that guides the computer to solve a problem. The process of writing a program is called programming. Many programming languages are available for writing various types of application, system software. System programming are designed to make the computer easier to use. An example is operating system. At present c C++ languages are widely used to develop system S/w. Application Programs are designed for specific computer applications such as payroll processing, inventory control etc. For writing application programs, the programmer does not need to control the basic circuitry of a computer system. One can chose any languages for writing a program according to 53 need.

Computing & Informatics


Types of Languages

L-13

Machine language: A first generation language written in binary form consist of two parts operation code and second is operand. Assembly language: Second generation language written in mnemonics form (symbol format), needs an assembler for translation into machine code.

High Level Language: Third generation language written in English


like language, easy to write programs needs compiler for translation to machine code.

Fourth generation Language: 4GL is a high level language that


requires significantly fewer instruction to accomplish a task uses the object oriented approach.
54

Computing & Informatics

Components of programming Language

L-13

To write a program in programming language the various concept such as representation of Datas, methods of expressing mathematical and logical relationship among data elements differs language to language but this are necessary parts of language. Variables, Constants, Data type, and expressions are the smallest components of a programming language. Variable: a character or group of characters assigned by the programmer to a single memory location and used in the program. Constant: it has fixed value in the sense that its value cannot be equal to any other value other than already assigned in the program. Data Type: defines a set of related values/ integers, numbers character and a specific set of specific operation that can be performed on those values.

55

Computing & Informatics


Components of programming Language

L-13

Data Type: different type of data types are integers, character, strings etc. Array: an array is a collection of same type of data (either string or numeric), all of which are referenced by the same name. Array: Normally two types of array are used. One dimensional Array A(X): it is a list of related data of same type referred to by the same variable name. Two Dimensional Array A (X,Y): it is used to represent the Datas

which are determined by two factors. It is defined by the rows and column value.
Expression: every computer language specify as in which various

arithmetic operators are used and evaluated in given expression. 56

Computing & Informatics

L-13

Components of programming Language


An expression may contain operators such as (), ^, -, *, /, +,. The operators mentioned above are called mathematical operators.

In a programming languages the logical operators are also used to perform the logical operations.
Some of relational operators are = equal to, <> not equal to, < les

than, > greater than, <= les than equal to, >= greater than equal to.
Every operators used in programming language has order of priority for solving the expression among themselves.

The logical operators are NOT, AND, OR, XOR, these four logical operators are sufficient to express any logical condition.
57

Computing & Informatics

L-13

Input and Output statement


Input statements are normally used for supplying values to a list

of variables through an input device such as key board.


During execution of input statement the program halt or waits for the response from the user. Output statements are used for providing the output of result of expressions or output of programs on monitor (normally) or in the

output devices.
Some times the output may given file or printed in a paper through printers.
58

Computing & Informatics

L-13

Assignment statement and print statement


This is the most used statement for assigning value to an identifier

(i.e. variables).
The syntax is : variable = expression (like X = A+B) This is a way to display values of specified list of variables on display screen. The syntax is printf( XXXXX); Print statement is also an output statement. computer languages normally provides very rich facilities for

making the display as attractive as possible.

59

Computing & Informatics

L-13

Conditional and looping statement


This is one of the most important program structure that enables a

modern programmer to develop well structured programs.


It accommodates statements corresponding to alternate tasks to be performed depending upon truth value of the condition. It has three components a conditional expression the truth value of which determines the action and an optional clause which

determines the other task to be performed if value is not truth.


It is used to provide loop structure in the program. The purpose of a loop is to repeat certain task until no more repletion is
60

desired.the for , while are most used loop statement.

Computing & Informatics

Subroutine and functions

L-13

While writing a program sometimes it is needed to repeat a group of statement at several points.

Subroutine is group of statement that can be referred to at different points in a program. It is group of statement that can be

executed from different points in program.


Function is rule or set of rules that assign one and only one value of X to give value Y. For Y = f(X) here Y is a function of X. Library functions are supplied by the language by default. The code for this functions does not appear in program. It is inserted
61 by the computer when program is translated into machine code.

Computing & Informatics

L-13

Algorithm and flow-chart


A computer works under instruction from the user. For solving any problem on a computer, the necessary instructions describing a scheme of solution for the problem are to be arranged and supplied by the user. The steps of of basic operations by following which a solution to a problem can be obtained constitutes what is called an algorithm. Once an algorithm for a problem is prepared, it can be used repeatedly for solving as many as instances of problem. A pictorial description of algorithm is used and is called Flow-chart. It also represent a clear graphical description of interdependence of

different steps of operation used in algorithm.

62

Computing & Informatics

L-13

Algorithm and flow-chart


The steps of operations used in an algorithm should be elementary that they can easily be performed by a computer, capable of executing previously mentioned instructions only or by a man who may not even have knowledge of the problem but capable of performing some operations only. Very precise description for operations used in the steps of an algorithm are necessary to avoid any sort of confusion. Algorithm must always halt after a finite time for the input values supplied to it. Algorithm must be very simple and descriptive in nature.
63

Computing & Informatics

Algorithm and flow-chart

L-13

Examples: find the Average of any three numbers.

1. Get the values of three numbers.

2. Compute the sum of the numbers.


3. Divide the sum by 3 to obtain the average. 4. Print the average value.

5. Stop.
Algorithm to swap the value of X and Y or interchange the values of X and Y.

1. Let a variable T.
2. T = X 3. X = Y

4. Y=T

64

Computing & Informatics

Algorithm and flow-chart

L-13

Algorithm to find the whether the given triangle is right angled.

1. Get the values of A, B, C. 2. SA = A*A, SB = B*B, SC = C*C 3. M = SA. 4. If SB > M then M = SB. 5. If SC > M then M = SC. 6. S = 0 7. If SA <> M then S = S + SA. 8. If SB <> M then S = S + SB. 9. If SC <> M then S = S + SC. 10. If S = M then print the triangle is right angled. 11. If S <> M then print triangle is not right angled
65

12. Stop.

Computing & Informatics


Algorithm and flow-chart

L-13

In flow charts the operations to be followed is represented by using nodes labeled with the symbols of operation and directed arcs. All nodes in a flow chart are not identical in shape. The shape of a node is determined by the type of operation it represent. Usually nodes are four types Input/Output boxes, Process boxes, Decision boxes and Start /Stop boxes. Get the value of variable I/P & O/P box A = A+1 Process Box Stop Start/ Stop Box

Is A>B Decision Box

66

Computing & Informatics

Algorithm and flow-chart


Start

L-13

Flow chart for average of three numbers.

Get values of X,Y, Z Compute SUM = X+Y+Z Compute AVE = SUM/3 Stop
67

Computing & Informatics

L-14

The C Languages Data types Input and output statement

Assignment statement

68

Computing & Informatics

The C Languages

L-14

C is a middle level language as it can function like a low level programming language to speed up processing as well as it can also work like high level language. Program written in C contains one or more function. A C program must contain a function called main and programs begin with main function.

The comments may also be incorporated for description purpose. The comment must be bounded by /* comments*/
The comment are omitted during compilation by compiler.

Basic block structure in C is


2 link Section 3 Definition Section 5 Main () 6{

1 comment line

4 Global declaration section

7 Declarative statement

8 executable statement

9}

69

Computing & Informatics

The C Languages

L-14

As example the first program in C is as.

/* This introductory program in C*/

# include <stdio.h>
Main () {

Printf ( Learn C Programming);


} The second line # include <stdio.h> is preprocessor directive which ensures reading an header file stdio.h. it is a command to the processor pass of compilation to perform a specific task. The third line is beginning of C program main function.
70

Computing & Informatics


Data Types

L-14

Character Set: four group namely letters a to z A to Z,digits, special character, white space are allowed in C. Identifiers: the word or names used to refer the variable, constant, function names are called as identifiers. A Key word defined in the C should not be used for any identifiers. Constant: it is an identifier whose value does not change in program. The four categories are Integers, Real,Character and String.

Integer constant refers to sequence of digits. Real constant is numeric constant with sign of decimal point or exponent or combination of both. Character constant is any symbol or value that is the part of valid list. 71 String is sequence of characters.

Computing & Informatics


Data Types

L-14

Variables: A variable is the meaningful name assigned represent a data object. Variable name must start with a letter. Variable name can not begin with digit. It can not contain punctuation mark math symbol or other special symbol. Reserved words name can not be used for variable name. ANSI restrict variable to be of 32 character. Variables are created to store the value of data object in the program. Result of an computational statement may be assigned to a variable.
72

Computing & Informatics

Data Types

L-14

Relational Operator: it is used to compare the value of two variable for various such as greater than, les than etc.

> is greater than, >= is greater than equal to, < is less than, <= is less than equal to, = = equal to, != not equal to. Logical Operator: an expression, which combines two or more relation operator is called logical expression. These expression results ion true or false.

&& is logical AND, !! Logical OR, ! is logical NOT.

Conditional Operator: it is used in place of if-then-else construct.

Exp1 ? Exp2 : Exp3, here Exp1is evaluated first if its found true then Exp2 is evaluated otherwise Exp3 is evaluated.
73 Val = (l>k) ? L : k here if L>k then Val will be = to l else Val = K.

Computing & Informatics


Data Types

L-14

Library Functions: the library functions are the well defined functions for performing the specific task in a program. The compiler evaluates these functions. In C some mathematical functions are also allowed, these functions are called mathematical functions. In order to use these library functions it is necessary to use header files. The header files are logical collection of various functions. If the header files are not included the functions can not be used. Some of the common header files are stdio.h, math.h, conio.h etc. The library functions are not the part of the language but these are supplied with the compiler.
74

Computing & Informatics


Input and Output statement

L-14

Input instruction is provided for getting necessary input from the user of the program. Scanf: this function is used to input a set of values.

scanf(FS, list of arguments) Here FS is known as format string and list of argument contains the variable in to which the value or data from the standard input will be stored. Example: scanf(%d %s %f, &integer1, string1,&integer2); This statement will store a decimal type integer data to integer1 (a variable defined in the program), string to variable String1 and floating point value to integer2 variable from the standard input. Each format must start with % sign & each numeric variable must 75 preceded by & sign.

Computing & Informatics


Input and Output statement

L-14

Output statement or instruction is provided for giving necessary output to the user of the program. printf: this function is used to print any combination of string, number or character to the standard output of computer (monitor).

printf(FS, list of arguments) Here FS is known as format string and contains the format characters for the corresponding variables. Example: printf(sum of %d and %d is = %d \n, integer1, integer2, integer3);

This statement will give the output as sum of 3 and 4 is=7


Where 3 is value of integer1,4 is value of integer2 and 7 is the value of integer3.

Each format must start with % sign.

76

Computing & Informatics

Assignment statement

L-14

Assignment operators are used to assign the result of computational statements. The assignment statement A O E; where a is variable and O is operator and E is expression. Example: X = P+Q*R+Z-T; Here after evaluation of P+Q*R+Z-T expression the resultant value will be assigned to variable X. Shorthand operator X+=3 is equal to X=X+3; X*=X is equal to X=X*X, X/=B+C is equal to X=X?(B+C)and X-=2 is X=X-2. Increment operator A++ or ++A increments the value of variable A by one. The difference is that a prefix operator first operates once to the operand and then result is assigned to variable to the left. Like A=1 B++A now A=2 and B=2 but B=A++ will be B=1 and A+2. 77 Similarly the decrement operator is A or A.

Computing & Informatics

L-15

Information system for decision making

Data management

Database management technology

Office automation system-LAN, WAN


78

Computing & Informatics

L-15

Information system for decision making

A system is a group of interrelated component working together towards a common goal in an organized manner. A system has three parts input, output and process. Input is given to the system (like raw material, Datas etc.), the given input is processed in processing element where the output generated as per the requirement. In the system feedback and control is used and such system is called cybernetic system. Feed back is a part of output used for modifying the input to improve the output. An information is a processed data or abstracted data from the available raw data. Information system is set of interrelated components that collect the input and process it to provide the desired information 79 (output) with the help of feedback and control system.

Computing & Informatics


Information system for decision making

L-15

A computer based information system has five basic components hardware software Data people and network. Hardware is physical computer equipment used to input output and processing, software is a computer program that includes the processing instructions to govern the operation of computer. People are the most important element in the most of systems as they are required to operate the system. Data is basically raw facts and observations. It is a valuable organized resource. Network are used to connect the computers and equipment in a building around a country or around the world. Decision making can be classified by organizational level corresponding to the strategic, management, knowledge and operational levels of the organization. Unstructured decisions are those in which decision maker must provide judgment evaluation and insights into problem definitions. Structured decisions are repetitive and routine and involve a 80 definite procedure.

Computing & Informatics

L-15

Information system for decision making


Normally the decision making consist of four stages intelligence, design choice and implementation.
Operational Knowledge
Structured Management Strategic

TPS
Office system

Semistructured

MIS DSS

Unstructured

KWS

ESS
MIS- Management information system DSS- Decision support system
81

TPS- Transaction processing system KWS- Knowledge work station ESS- Executive support system

Computing & Informatics


Information system for decision making

L-15

A decision support system is system that provides tools to mangers to assist them in solving semi structured and unstructured problems. A DSS is not intended to make decision but rather than to assist for decision making. Characteristics of DDS are they support semi structured or unstructured decision making. They are flexible enough to respond to the changing needs of decision maker and they are easy to use. The component of a DSS are hardware, software and data is necessary to provide interactive decision support. Management work station
Database Management Dialogue generation and management DSS generator Model Management

database

Decision maker

Interactive decision support

Model base 82

Computing & Informatics

L-15

Data management
Data management is the most important aspect for an organization since it provides the ability to complete most business activities.

Data management is a way of keeping the raw facts in special manner suitable to use it in efficient manner.
Data is generally organized in a hierarchy that begins with smallest data used by computer (bit). Character data is basic building block of information. Characters are put together to form a field. A collection of related fields is record. A collection of related records is a file. At the highest level of this data hierarchy is data base, a collection of integrated and related files. 83

Computing & Informatics

L-16

Data management

An entity is a generalized class of people, places or things for which data is collected stored and maintained. An attribute is a characteristics of of an entity. A collection of fields about a specific object is a record. A Key is a field or set of records that is used to identify the records. Normally there are two ways to mange the data. In Traditional approach separate data files are created and stored for each application program. One of the flaws of traditional file oriented approach is data duplication i.e. Data redundancy. When a change is made in one record it is not necessary that same will be done in other record. Data redundancy therefore conflicts with data integrity. In traditional approach another flaws is program-data dependence.
84

Computing & Informatics

L-15

Data management

Database approach utilizes the Datas in a more efficient way. A pool of related data is shared by multiple application programs. Some of the advantages of Database approach are: Improved strategic use of corporate data, reduced data redundancy, easier modification and updating data and program independence, better protection, standardization of data access etc. Database approach has some disadvantages like increased cost and specialized staff and increased vulnerability etc. Data modeling and database models are key considerations for any organization to choose the right approach. A data model is a diagram of entities and their relationship. Entity-relationship (ER) diagrams use basic graphical symbols to show the organization of and relationship between data. The structure in most database follows one of the three logical 85 database models hierarchical, network and relational.

Computing & Informatics

L-15

Data management

In a hierarchical database model, the data is organized in a top down or inverted tree structure. In network model an owner-member relationship instead of one to many relationship like in hierarchical model. The both models suffer from the deficiency that once the relationship is established the modification is difficult. In relational model all data elements are placed in two dimensional tables called relations that are logical equivalent to the files. The process of taking complex set of data and converting it into a set of simple tables is called data normalization. Basic data manipulations include selecting, projecting and joining. The data cleanup is used to develop the accuracy, flexibility, 86 relevancy, simplicity, verifiability in the data.

Computing & Informatics

Database management technology

L-15

A database management system (DBMS) is a group of programs used as an interface between a database and application programs or a database and the user. A dataware house is multidimensional database and is capable of storing very large amount of data generated from business applications. To retrieve data from the dataware house data mining tools are required. A DBMS also acts as a user interface by providing a view of the database. A subschema is file that contains the description of subset of the database and identifies which user can view and modify the data items in that subject. A data definition language (DDL) is collection of instruction and commands used to define and describe data and data relationship 87 in a specific database.

Computing & Informatics

Database management technology

L-15

The important aspect of DBMS is storing and retrieving the data from database.when database stores a data it utilizes the logical access path (LAP). Data manipulation language (DML) is collection of commands that are used to manipulate the database. Structured query language (SQL) lets programmers learn one powerful query language and use it on systems from PCs to the largest mainframe computers. SQL uses standardized and simplified procedures for retrieving storing and manipulating data in a database system. Database administration DBA is very important face of DBMS since the key issues like security, authorization, networking or communication data from one user to other user is controlled by DBA. Some popular DBMS are coral's Paradox, FoxPro, Microsoft 88 access, ORACLE etc.

Computing & Informatics

L-15

Office automation system-LAN, WAN


Office automation system simply helps in making an automated office having multiple functions to be performed. Presently business organizations are in the need of fast and accurate communication within the office as well as with their client so that a fully automated system can be developed. Basically three kinds of computer networks Internet, Intranet and Extranet are classified. Internet: a world wide system of computer network which is helpful to any office for providing connectivity with out side world. The internet provides a synthesis of computing and communication capabilities that adds valued to every part of the business cycle. An Intranet is a network within the organization. It uses information technology like web browser, and servers, TCP/IP client server network, hypermedia management system, HTML, 89 network management and security technology etc.

Computing & Informatics

L-15

Office automation system-LAN, WAN


An extranet is a network that links selected resources of the intranet of an organization with its regular customers. Computer networks are required to facilitate Internet, Intranet or Extranet. The computer networks are used to provide the file transfer between two systems, electronic mail (E-mail), execute a program on another computer, remote login, to share peripherals devices such as printers and to provide teleconferencing etc. The computer networks must have security measures against viruses and unauthorized access. The computer network must have reliability, less failure, less average down time, protection from catastrophe, suitable hardware software & transmission media. The network cost and traffic load and fixed cost & runtime cost are 90 important parameters to sorted out before a network is established.

Computing & Informatics

L-15

Office automation system-LAN, WAN


The function of a communication network is to interconnect DTE (data terminal Equipment). DTE is a general term to identify the end user machine which is usually a terminal or computer. Some example of DTEs are ATM, mobile phone a workstation for air traffic control, a personal computer at home or office. The communication between DTEs depends or based upon the Channel configuration, Transmission mode, Network topology design, Categories of networks. Channel configuration: Point to point channel configuration provides a dedicated link between two communication devices. Point to multi point channel provides a communication between single transmitter to may receivers. 91

Computing & Informatics

L-15

Office automation system-LAN, WAN


Transmission mode: Simplex is way of communication in which direction of data flow is in one way only in a single channel. Duplex is way of communication in which direction of data flow is in both direction in a single channel. Half Duplex permits transmission in both direction but in a one direction at time. Network topology Design: The topology means the form. Network may have any one of the following forms. Star topology each device is connected to a central device called hub the communication between to DTE is by using Hub only not directly. In tree topology the equipment are connected in a hierarchical 92 manner.

Computing & Informatics

L-15

Office automation system-LAN, WAN


Network topology Design: In Bus topology the equipment are connected with each other using a common bus. Ring topology a ring of connected equipment is formed. In mesh topology the each equipment is connected to each equipment using a dedicated link. Categories of network. Computer networks that are confined to a localized are I.e. an office are known as local area network LAN. Computer network based on DQDB (distributed queue dual bus) mechanism designed to extend over an entire city is Metropolitan Area Network (MAN). Computer networks that covers large geographical areas that may comprise a country a continent or even whole world is wide area 93 Network (WAN).

Computing & Informatics

L-16

C language

Control Structure

Array

94

Computing & Informatics

Control Structure

L-16

Decision making and looping is one of the basic construct of any programming language.

In C language the IFTHEN..ELSE, WHILE, DO..WHILE, FOR, BREAK and SWITCH are control structures statements.
If Then Else statement: is provided for decision making. If the out come of expression in If is true then the group of statement mentioned in Then clause is executed otherwise Else is executed.

If (condition expression)

{ Statement set1; }
Else { statement set2; }
95

Computing & Informatics

Control Structure

L-16

/* largest of three numbers */ # include <stdio.h> Main () { int a,b,c; printf (Please enter all the three A, B and C number\n); scanf (%d %d %d,&a, &b, &c); if (a>b) { if(a>c) { printf(Largest number is %d\n, a); } else { printf(Largest number is %d\n, c); } } else { if (c>b) { printf(Largest number is %d\n, c); } else { printf(Largest number is %d\n, b); } } }

96

Computing & Informatics

Control Structure

L-16

#include <stdio.h> #include<conio.h> void main() { int a,b,c; char X; clrscr(); printf (" please enter all the three numbers A B and C\n"); scanf("%d %d %d",&a,&b,&c); if(a>b) { if(a>c) { printf("largest number is %d\n",a); } else { printf("largest number is %d\n",c); } } else { if (c>b) { printf("largest number is %d\n",c); } else { printf("largest number is %d\n",b); } } getch(); }

97

Computing & Informatics

Control Structure

L-16

While statement: is provided for repeated execution of statements. The statements are executed until the condition is fulfilled. While (condition expression) { Statement set; } /* this is a program to calculate m to the power n*/ #include<stdio.h> #include<conio.h> main() { int m,n,count; 98 Float pow;

Computing & Informatics

Control Structure

L-16

/*body of program*/ printf("This program gives the M to power N\n"); printf("Please give value of M and N\n"); scanf("%d %d",&m,&n); count=1; pow = m; while(count<n) { pow=pow*m; count++; } printf("\n The %3d to the power %3dis=%4d\n",m,n,pow); getch(); 99 return 0;}

Computing & Informatics

Control Structure

L-16

The out put of the program will be as follows:

This program gives the M to power N Please give value of M and N 2 5 *(press enter here)* The 2 to the power 5 is = 32 On second run: This program gives the M to power N Please give value of M and N 11 6 The 11 to the power 6 is=1771561.000000
100

Computing & Informatics

Control Structure

L-16

Do-while statement: is also provided for repeated execution of statements. The statements are executed until the condition is fulfilled.The difference with while statement is that condition is evaluated after execution of statements. Do { Statement set; } While (condition expression) So in the last program the condition with do-while will be as: do { pow=pow*m; count++; } 101 while(count<n);

Computing & Informatics

Control Structure

L-16

For statement: it is also provided for repeated execution of statements. The statements are executed until the condition is fulfilled. for (expression1; expression2; expression3) { Statement set; } So in the program to calculate the m to the power n will be as : for (count=1;count<n;count++) { pow=pow*m; }
102

Computing & Informatics

Control Structure

L-16

switch statement: this statement in C provides the multiple branch selection. It checks for value of an expression against a list of integer or character. If the match is successful, the group of statement is executed
Switch (expression) { caseconstant 1: Statement set2; break; caseconstant 2: Statement set2; break; case constant 3: Statement set3; break; . . Default: Statement set3; }

103

Computing & Informatics

Control Structure

L-16

Break and Goto statement: these statements are used in C to change the flow of execution. The break is used in conjunction with switch case however this statement can be used to discontinue the loop.
Main() { int I=1; While (I<100) { printf( the number = %d\n,I); I++ If (I==20) break; } }

Use of go to
Goto LABLE; Statement set1; . . LABLE: statement set 3;

104

Computing & Informatics


Arrays

L-16

An array is a collection of variables of same type that are represented by common name. A specific element of an array is accessed by an index. A one dimensional array is defined by its type followed by an identifier with a expression.the O/p of expression must be +ve.

int salary[10] char name[25] float amount[12] float Matrix[3][4]

As indicated above the elements of an array can be initialized as the other variables at the time of declaration.like:
105

Int height[5] = {123,124,122,121,112};

Static char name[3] ={s,e,g};

Computing & Informatics


Arrays

L-16

All the arrays declaration define the maximum size of an array thus they are called static array. In C flexibility is provided for not defining the size of an array. A programmer may leave the size of an array unspecified.the total numbers of entries specified in the list of values defines the maximum size of array. It is not possible to process an array in a single shot. If an operation is to be done on array, it must be element basis. This is usually done using For loop, Do-while etc. on element basis. In the next slides the multiplication of two matrix is explained using the arrays.
106

Int student[ ] = {12,13 12, 14};

Computing & Informatics Arrays


/* The program for the multiplication of two matrix */ #include<stdio.h> #include<conio.h> #define M 5 void main() { int i,j,r1,r2,c1,c2,x; int a[M][M],b[M][M],c[M][M]; clrscr(); printf("program for multiplication of two matrix\n"); printf("The column of FIRST Matrix should be equal to row of SECOND Matrix\n"); printf("Give the no of rows in the First Matrix\n"); scanf("%d",&r1); printf("Give the no of column in the First Matrix\n"); scanf("%d",&c1); printf("Give the no of rows in the Second Matrix\n"); scanf("%d",&r2); printf("Give the no of column in the Second Matrix\n"); scanf("%d",&c2);

L-16

107

Computing & Informatics

Arrays

L-16

/* To check the possibility of multiplication*/ if(c1!=r2) { printf("The Multiplication is not Possible sorry^^^\n"); } else { /* To read the first MATRIX*/ printf("Give the give the elements of first Matrix\n"); for(i=0;i<r1;i++) { for(j=0;j<c1;j++) { printf("Give the %d row & %d column element of first Matrix\n",i+1,j+1); scanf("%d",&a[i][j]); } } /* To read the second MATRIX*/ printf("Give the give the elements of Second Matrix\n"); for(i=0;i<r1;i++) { for(j=0;j<c1;j++) { printf("Give the %d row & %d column element of Second Matrix\n",i+1,j+1); scanf("%d",&b[i][j]); } }

108

Computing & Informatics

Arrays

L-16

/* To Show the First MATRIX*/ printf("The First Matrix is \n"); for(i=0;i<r1;i++) { for(j=0;j<c1;j++) { printf("%5d",a[i][j]); } printf("\n"); } /* To Show the SECOND MATRIX*/ printf("The Second Matrix is \n\n"); for(i=0;i<r1;i++) { for(j=0;j<c1;j++) { printf("%5d",b[i][j]); } printf("\n"); } /* now the multiplication*/ for(i=0;i<r1;i++) { for(j=0;j<c2;j++)

109

Computing & Informatics

Arrays

L-16

/* now the multiplication*/ for(i=0;i<r1;i++) { for(j=0;j<c2;j++) { c[i][j]=0; for(x=0;x<c1;x++) { c[i][j]=c[i][j]+a[i][x]*b[x][j]; } } } /* To Show the OUTPUT MATRIX*/ printf("The Multiplied or Output Matrix is \n\n"); for(i=0;i<r1;i++) { for(j=0;j<c2;j++) { printf("%8d",c[i][j]); } printf("\n"); } } printf("\n THANK YOU\n"); getch(); }

110

Computing & Informatics

Arrays

L-16

The output of the program is as follows:


program for multiplication of two matrix The coloumn of FIRST Matrix should be equal to row of SECOND Matrix Give the no of rows in the First Matrix 2 Give the no of coloumn in the First Matrix 2 Give the no of rows in the Second Matrix 2 Give the no of coloumn in the Second Matrix 3 Give the give the elements of first Matrix Give the 1 row & 1 coloumn elementof first Matrix 1 Give the 1 row & 2 coloumn elementof first Matrix 3 Give the 2 row & 1 coloumn elementof first Matrix 2 Give the 2 row & 2 coloumn elementof first Matrix 4 111

Computing & Informatics

Arrays

L-16

Give the give the elements of Second Matrix Give the 1 row & 1 coloumn elementof Second Matrix 1 Give the 1 row & 2 coloumn elementof Second Matrix 3 Give the 1 row & 3 coloumn elementof Second Matrix 5 Give the 2 row & 1 coloumn elementof Second Matrix 2 Give the 2 row & 2 coloumn elementof Second Matrix 4 Give the 2 row & 3 coloumn elementof Second Matrix 6 The First Matrix is 1 3 2 4 The Second Matrix is 1 3 5 2 4 6 The Multiplied or Output Matrix is 7 10 15 22 23 34 112 THANK YOU

You might also like