part ii software assignment - sutirtha

Upload: sutirtha-bhaumik

Post on 07-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Part II Software Assignment - Sutirtha

    1/160

    UNIVERSITY OF CALCUTTA

    B.Sc. PART II (HONOURS) EXAMINATION - 2010(UNDER 1 + 1 + 1 NEW REGULATION)

    Paper 4B

    SOFTWARE ASSIGNMENT ON SINGLE USER AND MULTIUSER OPERATING SYSTEM AND

    PROGRAMMING THROUGH C LANGUAGE

    ROLL NUMBER: 301241 0121

    REGISTRATION No. & SESSION: 030429 of 20082009

  • 8/6/2019 Part II Software Assignment - Sutirtha

    2/160

    - 2 -

    INDEX

    Section I:

    Familiarity with single user and multi user operating systems:

    SerialNumber

    Contents Page Date TeachersSignature

    1 Microsoft DOS (Disk Operating System) 6 16.09.2009.

    2 Microsoft Windows (Including MicrosoftWord, Microsoft Excel) 14 23.10.2009.

    3 UNIX Operating System 32 28.10.2009

    Section II:

    Programming in C Language:

    SerialNumber Contents Page Date TeachersSignature

    1 Program in which for all integers I,J,K,L

    from 1 to 10, all combinations of I,J,K,L are printed such that I+J+K=L and I

  • 8/6/2019 Part II Software Assignment - Sutirtha

    3/160

    - 3 -

    5 Write a menu driven program to find thevalue of sin(x), cos(x), e^(x), log(x) 53 20.11.2009.

    6 Program to find the saddle point in a given

    matrix 60 25.11.2009.

    7 Program to check if a square matrix is skew-symmetric 63 27.11.2009.

    8 Program to implement matrix multiplicationof chain of matrices 66 04.12.2009.

    9 Program to compute real roots of a non-linear equation by Newton Raphson method 71 11.12.2009.

    10 Program to find integration using

    Trapezoidal rule and Simpsons 1/3 rule for afunction

    74 16.12.2009.

    11 Program to find inverse of a matrix 77 18.12.2009.

    12 Program to print a normal input stringvertically where each character in the outputstring is in uppercase

    82 23.12.2009.

    13 Program to squeeze the blanks (more thanone) from a given string 84 06.01.2010.

    14 Program to convert a full name into itsappropriate abbreviated form 86 08.01.2010.

    15 Program to find the minimum spanning treeusing Prims algorithm 88 15.01.2010.

    16 Program to find the shortest distance andshortest path between any vertex to any

    vertex using Floyds algorithm 92 22.01.2010.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    4/160

    - 4 -

    17 Program to find the shortest distance from

    one vertex to all vertices in a directed graph by Dijkstras method

    96 27.01.2010.

    18 Program to implement a queue using array 101 29.01.2010.

    19 Program to simulate different sortingtechniques through menu driven program 107 03.02.2010.

    20 Program to build a binary search tree having

    characters as content of each node andtraverse it in preorder, inorder, and postorder

    128 05.02.2010.

    21 Program to create a general binary tree andtraverse it in preorder, inorder, and postorder 133 10.02.2010.

    22 Program which accepts a string of

    parentheses and checks whether the string isvalid in algebraic sense

    138 17.02.2010.

    23 Program to convert decimal numbers toroman numerals 142 19.02.2010.

    24 Program to find the age of people 147 24.02.2010.

    25

    Program that accepts three text files (say f1,f2, f3) as command line arguments and

    merge lines alternately from two files f1and f2 and writes the results into the third

    file f3. Finally print all the three files.

    150 05.03.2010.

    26 Program to print Pascals triangle up to nlevel 155 10.03.2010.

    27 Program to print a particular pattern tonumbers in screen 158 12.03.2010.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    5/160

    - 5 -

    Section- I

    Familiarity with Single User and Multi userOperating Systems

  • 8/6/2019 Part II Software Assignment - Sutirtha

    6/160

    - 6 -

    ASSIGNMENT No. 1 Date: 16.09.2009.

    Microsoft DOS (Disk Operating System)

    An Operating System (OS) is the most important system software and is a must to oper

    computer system. An OS manages computer resources very effectively, takes care of schemultiple jobs for executions and manages the flow of data and instructions between the inputunits and the main memory. Popular OSs are WINDOWS-95/98 , WINDOWS 2000 , WIND NT , UNIX , LINUX , DOS etc. In other words, an OS is a program that acts as an interm between the user and the computer.

    Introduction:DOS (an acronym for Disk Operation System) is a tool which allows you to contro

    operation of the IBM PC. DOS is software which waswritten to controlhardware . IDRISI,Atlas*GIS, Micro station, AutoCAD, CPS/PC, and ARC/INFO are, in turn, application sowhich run under DOS. By this we mean that, although IDRISI, Atlas*GIS, Micro station, AutCPS/PC, and ARC/INFO were written to accomplish a single task or application (in this

    manipulation of spatially related data), they must use DOS to pursue its work.DOS can be used for a wide range of tasks far beyond the requirements of this class. You

    be able to manage well if you master only a small subset of DOS commands and functionsrelate almost exclusively to file and directory management and are introduced in this handout.

    This tip sheet assumes that you have learned how to turn on the PCs as they are configuroom 230 and that you have familiarized yourself with their keyboards (no small task in itself)assumes that you understand the meaning of the concept of a file and the elements of a filespecification (drive, filename, and extension). The microcomputers you will be using are eqwith two floppy disk drives. The A-drive is the 3.5" (1.44MB) drive and the B-drive is the 5.2(360KB) drive. The microcomputers also contain a C-drive, a hard disk drive of 130MB or 2capacity.

    You will quickly find that the best way to learn how to use a computer is throuexperimentation. That is, once you have learned a command, try some variations until thework, then start over. Often there are five or six ways for you to accomplish a particular task. UI will introduce you to only one, leaving it up to you to discover the rest. Don't hesitate to conDOS Reference Manual; copies can be found on the bookcase in room 230. Finally, don't be disturbed by error messages. With computers, one of the best ways to learn is by making mistak

    Most of the common DOS commands you need to use for this class (copy, rename, deletavailable to you in Windows through the Filemanager icon. And, since you can move back an between DOS and Windows, it doesn't matter which option you employ. Some commands arein invoke in Windows, some in DOS. If you haven't worked with Windows previously, go Windows tutorials in the help area.

    Booting Sequence:As soon as P.C is switched on it runs program that is permanently stored in its memory

    program is called Basic Input Output System(BIOS) and it is always there, whether or not yoany disk loaded and even when the power is turned off. Upon startup, BIOS automatically loothe PCs master computer program, first in the A:\ drive, if a floppy drive is loaded, otherwiseC:\ drive.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    7/160

    - 7 -

    MS-DOS comprises of three files :--1. IO.sys2. MS-DOS.sys3. COMMAND.com

    What are FILES?

    Files are a collection of records. Concept of files is very important in DOS. There are files in DOS. They are as follows:1. Data files.2. Program files.3. Sub Directory files.

    Every file name has two parts:1. File name2. Extension

    y File name should not contain more than 8 letters and extension should not conmore than 3 letters.

    y File name part identifies the particular file and extension identifies the category offiles.

    File Allocation Table (FAT):Following the boot sector comes the FAT that keeps track of all the disk space

    the device to provide reliability, sometimes the FAT is replicated. The FAT contains oneentry for each block on the disk. The block size is given in the boot sector and can range frosectors. The size of the FAT entry is 16 bits. The free blocks are marked by another code in the

    A directory in DOS has a 32-bit entry for each file name and directory it contains. The11(8+3) characters hold the file name and extension. Next comes the attribute byte containfollowing bits.

    A Archive bit (set when the file is modified, cleared when it is backed up).D set to indicate that the entry is for a directory.V set to indicate that the entry is for volume label.S set for system (undeletable file).

    IO.SYSMS-DOS.SYSALL.SYS files.

    H set for hidden files.R read only bit.

    The time and date of the last modification are stored in the next two fields.

    4bits hours.6bits minutes.6bits seconds.

    7bits years.4bits months.5bits days.

    The last two fields hold the number of the first block and the file size.

    File Name

    Extension A D V S H R Future Timeuse

    Date 1st block

    Filesize

  • 8/6/2019 Part II Software Assignment - Sutirtha

    8/160

    - 8 -

    What are DOS commands?A command is defined as something that is typed in a line on the screen of the DOS pr

    The command may consist of single word or more. There are three types of commands.They are as follows:

    1. Internal commands.2. External commands.

    Internal Commands:A handful of the smallest and the most useful commands are a resident part of DOS. T

    are called the internal commands.

    External Commands:All other command programs in DOS are called external commands, and they are

    stored in the disk until they are needed.

    Now the important DOS commands are given below.

    Date and Time:To modify and see the date and time, we use the following command.

    C:\>date The current date is: Thu 07/14/2005Enter the new date: (mm-dd-yy)

    C:\>time The current time is: 15:02:24.24Enter the new time:

    Volume Label of a Disk To display the volume label on a disk, we use the following command.

    C:\>vol Volume in drive C is WINDOWS 98

    Volume serial number is 0448-16FFVersion of MS DOS

    To display the MS-DOS version we use the ver command.C:\>ver Windows 98 [version 4.10.2222]

    Clear ScreenThe cls command clears the screen.

    C:\>cls

    Backup Files

    It is possible to lose files by mistake, although the more you practice the less like becomes. For your own peace of mind, it is good practice to make backup copies of youvaluable files on a separate diskette. Store your backup disk in a safe place and don't carry it thmetal detector. Use the COPY command to create the backup.

    There is no need to backup every file you create, only the ones in which you've investedwork. Also, prune your backup diskette every week or two using the ERASE command. Backuwhich have been made redundant by subsequent additions will simply create clutter on your diskette. An effective file naming convention is essential to keeping track of your backups.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    9/160

    - 9 -

    Change the Default Drive:To change the default drive, simply type the letter of the your choice. The new default will be lsubsequent DOS prompts.

    Example:

    y C:\> A: y Changes the default drive from C to A.y A:\> C: y Changes the default drive from A to C.

    [enter] means that you must press the Enter Key before the format command willexecute . [Enter] isrequired after any DOS command, it is assumed in all commands found below.

    CHDIR (CD) Change Directory Command

    Once you have located the directory you want, you may move from directory to directory usCD command (change directory)

    Example:

    y C:\> cd furniturey Moves you to the directory called 'FURNITURE'y C\:> cd \furniture\chairsy Moves you to the directory called 'CHAIRS' under the directory called 'FURNITURE'.y C:\> cd..y Moves you up one level in the path.y C:\> cd\y Takes you back to the root directory (c: in this case).

    COPY Command

    The COPY command can be used both to copy files from disk to disk or to create a second cofile on a single disk. (There are many more uses of the COPY command, but only the basic opis discussed here.)

    Example:

    y C:\> copy c:kermit.exe a:y Copies the file 'KERMIT.EXE' from the C drive to the A drive and gives it the same namy C:\> copy a:brazil1.dat b:\south\brazil2.daty Creates a copy of 'BRAZIL1.DAT' from drive A on drive B, putting it in the 'SOU

    subdirectory and renaming it 'BRAZIL2.DAT'.

    The key to use this command correctly is to remember that the first file specified after the Ccommand is the source file, the second is thetarget :ehp1 file. The source is the file to be copied. Thetarget will be the location and name of the new file. If the file name and extension are omittedthe target's drive specification, the new file will have exactly the same name as the source file.

    Example:

    y C:\> copy a:myfile.txt b:y C:\> copy c:command.com b:com.com

  • 8/6/2019 Part II Software Assignment - Sutirtha

    10/160

    - 10 -

    y C:\> copy b:golly.gee a:whao.boyy C:\> copy command.* a:y C:\> copy a:mymap.dwg c:\maps

    Note: it is always good practice to us the complete file specifications for both source and targBe very sure of yourself before you accept defaults or employ wild-card characters. Otherwi

    may end up with some interesting results. Incomplete or incorrect source names may result in such as the command: copy edlin a:myomy.bat. Try it and see what happens.

    DIR (Directory) CommandThe DIRECTORY command lists the names and sizes of all files located on a particular disk.

    Example:

    y C:\> dir a:y Shows directory of drive Ay C:\> dir b:y Shows directory of drive By C:\> dir \windowsy Shows files in a subdirectory on drive C (default)y C:\> dir y Shows directory of drive Cy C:\> dir /wy Shows directory in wide format, as opposed to a vertical listing.

    All the files are listed at the screen, you can stop the display by typing CTRL-BREAK. If you a directory on the A or B drives, be sure there is a diskette in the drive and that the diskette haformatted. If the drive is empty, or if the diskette is unformatted, the DOS will respond with anerror message .

    DIR Options

    Two little characters, '*' and '?', will make your life with computers much easier. Their uillustrated below.Example:

    y C:\> dir a:*.exy Lists all files on the A drive with an extension of 'EXE'.y C:\> dir b:kermit.*y Lists all files on the B drive with a filename of 'KERMIT'.

    The asterisk is a wild-card character which allows the user to enter only a limited part of specification to find a file. It is useful when you wish to locate a group of files with the same fior the same extension. On other occasions you may have forgotten part of a file specification. Yuse '*' in place of the parts of the specification you have forgotten. Similarly, '?' permits wilsearches keyed to single characters.Example:

    y C:\> dir a:labe?.comy Lists all five-letter files with the first four letters 'LABE' and an extension of 'COM'.y C:\> dir b:format.c??y Lists all files with a filename of 'FORMAT' and an extension beginning with 'C'.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    11/160

    - 11 -

    Wild-card characters can be used in combination.

    Example:

    y C:\> dir a:labe?.*y Lists all five-letter files with the first four letters 'LABE' and any extension.y

    C:\> dir c:*.ex?y Lists all files with an extension beginning with 'EX'.

    Experiment with '*' and '?' to improve your ability to find files quickly. These wild-card charcan also be used with several other DOS commands.

    TYPE CommandThis command is used to display the contents of the file with the extension name o

    screen.C:\>type filename

    Ex:C:\>type scott.doc

    I am a student of Asutosh College.

    ERASE CommandThe ERASE command deletes specified files.

    Example:

    y C:\> erase a:myfile.txty Erases the file MYFILE.TXT from the diskette in the A drive. If no drive specificati

    entered, the system looks to delete the specified file form drive C (in this case).

    IMPORTANT WARNING: This command is easy to use, but it is the most dangerous one yoencounter in DOS (apart from FORMAT). If you aren't careful, you may delete a file which ysomeone else--needs. And, unless you have saved a backup of that file, the erased file is gogood. For this reason it is good practice to use only complete file specifications with the Ecommand (and to keep backups of your most valuable files). As a safety precaution, never wild-card characters '*' and '?' in ERASE commands.

    BEWARE: I will rescind your laboratory privileges for a full week if you ever knowingly usethe command: erase c:*.*, or the command: erase *.*. Guess what happens?

    File-Naming ConventionsCareful file naming can save time. Always choose names which provide a clue to the file's contyou are working with a series of related files, use a number somewhere in the name to indicateversion you have created. This applies only to the filename parameter; most of the file ext parameters you will be using are predetermined (or reserved by DOS for certain types of file).

    Example:

    y WORLD.DATy An ATLAS*GRAPHICS file containing data for a world map. The DAT extension is req

    by ATLAS*GRAPHICS.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    12/160

    - 12 -

    y BRAZIL.BNBy A boundary file of Brazil in binary form.y BRIT1.DATy BRIT2.DATy BRIT3.DATy Three versions of a data file for a map of Britain.

    FORMAT CommandYou must format new disks before using them on the IBM computers. The format command chdiskette for flaws and creates adirectory where all the names of the diskette's files will be stored.

    Example:

    y C:\> format a:y Formats the diskette in the A drive.y C:\> format b:

    After entering this command, follow the instructions on the screen. When the FORMAT opera

    complete, the system will ask if you wish to FORMAT more diskettes. If you are working witone diskette, answer N (No) and carry on with you work. If you wish to FORMAT several diskettanswer Y (Yes) until you have finished formatting all your diskettes.

    BEWARE: Executing the format command with a diskette which already contains files will rethe deletion of all the contents of the entire disk. It is best to execute the format command onew diskettes. If you format an old diskette make sure it contains nothing you wish to save.

    MKDIR (MD) Make Directory CommandThis command creates a new directory.

    Example:

    y C:\> mkdir miney Creates a directory called 'MINE'

    Rebooting the computer (Ctrl-Alt-Del)In some cases, when all attempts to recover from a barrage of error messages fails, as a last rescan reboot the computer. To do this, you press, all at once, the control, alternate and delete.

    BEWARE: If you re-boot, you may lose some of your work--any data active in RAM which hyet been saved to disk.

    RENAME (REN) CommandThe RENAME command permits users to change the name of a file without making a copy of i

    Example:

    y C:\> ren a:goofy.txt pluto.txty Changes the name of 'GOOFY.TXT' on the A drive to 'PLUTO.TXT'.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    13/160

    - 13 -

    This command is very simple to use, just remember two points: the file name and extension mcomplete for the source file and no drive specification is given for the target. Renaming caoccur on a single disk drive (otherwise COPY must be used).

    RMDIR (RD) Remove Directory CommandThis command removes a directory. It is only possible to execute this command if the directowish to remove is empty.

    Example:

    y C:\> rd miney Removes directory called 'MINE'.

    Stop Execution (Ctrl-Break)If you wish to stop the computer in the midst of executing the current command, you may use sequence Ctrl-Break. Ctrl-Break does not always work with non-DOS commands. Some so packages block its action in certain situations, but it is worth trying before you re-boot.

    Tree CommandTREE command displays the list of all the branches of the directory tree for any disk. Example

    C:\>md a C:\>cd a C:\a>md pqr C:\a>md xyz C:\a>cd pqr C:\a\pqr>md p C:\a\pqr>md q C:\a\pqr>md r C:\a\pqr>cd.. C:\a>cd xyz C:\a\xyz>md x C:\a\xyz>md y C:\a\xyz>md z C:\a\xyz>cd.. C:\a>tree Folder PATH listingVolume serial number is 71FAE346 38A6:8127C:.

    pqr | p| | q

    | r xyzxy

    z

  • 8/6/2019 Part II Software Assignment - Sutirtha

    14/160

    - 14 -

    ASSIGNMENT No. 2 Date: 23.10.2009.

    MICROSOFT WINDOWS

    Introduction:

    The Microsoft windows operating system is a 32 bit primitive multitasking operasystem for Intel Pentium and later microprocessors. Key goals for the system are portasecurity, Portable Operating System interface (POSIX), compliance, microprocessor suand compatibility with MS-DOS and Microsoft windows applications. Windows uses kernel architecture, so enhancements can be made to one port of the operating system wgreatly affecting other parts.

    What is Windows?

    Microsoft Windows is a software program that makes the PC easy to use. It doessimplifying the computer user interface a buzzword that refers to the way the compugiven command, the way it is interacted with.

    Usually the interface between the user and the computer consists on the screen ankeyboard; the user interact with the computer by responding to what is on the screen, tin cryptic command at the DOS command line to the work. DOS often is not very intelat interpreting your commands and most people consider it awkward or intimidating is interface. These commands can be confusing and difficult to remember. What has missing from the PC is a program and WINDOWS is such a program. With Wind program can be opened, entered and moved, that was stored and performed in DOS, justhe help of a mouse and a keyboard.

    Windows owes its name due to the fact it runs each program on a separate windoits own. Many windows can be opened on the screen. The user has to shift from progr program just by switching over to different windows. There is no need of closing program. Windows has a facility called the clipboard that led the user to copy any tydata from any program to another. All application programs that runs on windows has sfeatures.

    Hardware Requirements:

    To run Microsoft Windows 3.1 the following hardware are required:y A PC, with DOS ver 3.1 and hard-disk having a minimum of 9MB free space.y A mouse.y 1 MB of memory.y A monochrome graphics monitor or colour monitor.y A graphics adapter card.

    Design Principles:The design goals that Microsoft has stated for Windows includes :--

    y Extensibility: It refers to the capacity of the operating system to keep up wadvances in computing technology.

    y Portability: An operating system is portable if it can be moved from one hard-warchitecture to another with relatively few changes.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    15/160

    - 15 -

    y Reliability: It is the ability to handle error, including the ability of the operasystem to protect itself and its users from defective or malicious softwacompatibility.

    y Compatibility: Windows provides source-level compatibility to applications follow the POSIX standard. Thus they can be compiled to run on Windows withchanges to the source code.

    y Performance: Windows is designed to afford good performance. The subsystethat constitute windows can communicate with one another efficiently by a lo procedure-call facility that provides high performance message passing.

    Basics of Microsoft Windows: A window is a rectangular portion on the screen in which an application or a prodisplays information. Most Windows have certain elements in common. They are as fol

    y Title bar displays name of the application or document.y On the extreme left of every title bar there is an icon called system control icon.y The menu bar lists the available menus.y Scroll bars are used for viewing unseen portion of list and other information

    cannot fit in the allocated space.y Most windows have a maximize, minimize and a close button. These buttons

    used for resizing and closing windows.

    Application Icon:

    It represents an application that is running. You can move an icon anywhere ondesktop by clicking on the left mouse and dragging it. You cannot move the icon insdocument or another application.

    Program Item Icon:

    This represents the applications which can be started from windows. They are usunique and are contained in the program managers group windows.The rectangular bar that runs horizontally across the bottom of your screen is called tasIt includes Start button, current time, and when you start working you will see other listed on the task bar. This item shows you the name of the windows currently open ondesktop. You can easily switch to different windows by clicking on its taskbar button.

    Elements of the Desktop:

    The desktop has a number of application program or some files or folder on it. Somwhich are as follows:

    y My computer.y Recycle Bin.y My Documents.y Task bar.y Start Menu.y Shortcuts.

    My Computer:

    My Computer is used to view the contents of a single folder or drive. Double cliccomputer on your desktop to display the drives available on your computer. When

  • 8/6/2019 Part II Software Assignment - Sutirtha

    16/160

    - 16 -

    double click a drive icon, a window displays the folders on that drive. There shall be fofor Control Panel, Printers and Dial up networking. Double click a folder to see thewithin the folders.

    Recycle Bin:

    Recycle Bin is a application program which contain all the deleted files and foldSo if something is deleted by mistake, it can be restored from Recycle Bin using the roption and to completely delete the folder we select the delete option available. To eRecycle Bin, right click on the Recycle Bin folder on the desktop and select the ERecycle Bin option by clicking on it or enter the Recycle Bin folder on the desktopchoose the Empty Recycle Bin option available on the right hand side.

    My Documents:

    My document is a desktop folder that provides a user with a convenient place to documents, graphics or other files which a user might want to access quickly. On the dea folder with a sheet of paper on it represents it. When a user saves a file in a program sMS Word, MS Excel, WordPad, Paint etc. the file is automatically saved in My Documunless a user select some other location.Using the Control Panel:

    The control panels customize your windows environment. The control Panel windows consisting of collection of utilities to set your screen colour, modify the appeaof your desktop, change date and time.The control panel helps in the following :--

    y Setting date and time.y Display .y Changing pattern.y Loading new wallpaper.y Loading screen saver.

    To start window explorer:

    y Click the start button on taskbar.y Click the program and select window explorer.

    The left pane of the window explorer screen shows the directory structure while the pane shows the directories and files in the directory selected.

    Creating a new Folder on the Desktop:

    To create new folders follow the following steps:y Click the right mouse button anywhere is an empty area on the desktop, a m

    appears.y Select NEW from the menu.y Click on the folder option.y A new folder appears on the desktop having its name as New Folder.

    Creating a new File on the Desktop:

    y Open the Windows Explorer window.y Open the folder in which the file is to be created.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    17/160

    - 17 -

    y Open the file menu and choose NEW option from the menu.y Select the type of file and give name to the file.

    Copying a file or folder:

    y Select the file or folder you wish to copy.y

    Choose the option copy from the context menu, click on it and paste on the talocation again by choosing the paste option from the context menu.

    Deleting a file or folder:

    y Select the file or folder you wish to delete.y Select the delete option from context menu and click on it.

    Renaming a file or folder:

    y Select the file or folder you wish to rename.y Select the rename option from context menu and click on it.y Type the new name in the text box and press enter.

    Setting the screen colours:

    y Double click on the display icon a dialog appears.y Click down arrow on the side of the colours schemes box.y Select one of the schemes from the list.y The screen colours in the sample screen are set to the colours used in the sche

    selected.y Click OK at the bottom of dialog box.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    18/160

    - 18 -

    MICROSOFT WORD

    Question 1:

    Create a document in MS WORD containing several paragraphs.

    a) Copy the first paragraph of the document in a new page.

    b) For all the paragraphs change the line spacing to double and spacin g after aparagraph to 6 points

    Answer:A computer is a machine for manipulating data according to a list of instructions.

    Computers take many physical forms. Early electronic computers were the size of a room, consuming as much power as several hundred modern personal computers.[1] Today,computers can be made small enough to fit into a wrist watch and be powered from a battery. Society has come to recognize personal computers and their portable equivalen

    laptop computer, as icons of the information age; they are what most people think of computer". However, the most common form of computer in use today is by far embedded computer. Embedded computers are small, simple devices that are often uscontrol other devicesfor example, they may be found in machines ranging from figaircraft to industrial robots, digital cameras, and even children's toys.

    The ability to store and execute programs makes computers extremely versatiledistinguishes them from calculators. The ChurchTuring thesis is a mathematical stateof this versatility: Any computer with a certain minimum capability is, in principle, caof performing the same tasks that any other computer can perform. Therefore, compwith capability and complexity ranging from that of a personal digital assistant supercomputer are all able to perform the same computational tasks as long as timestorage capacity are not considerations.

    It is difficult to define any one device as the earliest computer. The very definitioa computer has changed and it is therefore impossible to identify the first computer. Mdevices once called "computers" would no longer qualify as such by today's standOriginally, the term "computer" referred to a person who performed numerical calculatihuman computer), often with the aid of a mechanical calculating device. Examples ofmechanical computing devices included the abacus, the slide rule and arguably the astrand the Antikythera mechanism (which dates from about 150-100 BC). The end oMiddle Ages saw a re-invigoration of European mathematics and engineering, and WiSchickard's 1623 device was the first of a number of mechanical calculators constructEuropean engineers.

    However, none of those devices fit the modern definition of a computer because could not be programmed. In 1801, Joseph Marie Jacquard made an improvement ttextile loom that used a series of punched paper cards as a template to allow his looweave intricate patterns automatically. The resulting Jacquard loom was an important sthe development of computers because the use of punched cards to define woven patter be viewed as an early, albeit limited, form of programmability.

    In 1837, Charles Babbage was the first to conceptualize and design a fu programmable mechanical computer that he called "The Analytical Engine".[2] Due to limitedfinance, and an inability to resist tinkering with the design, Babbage never actually buAnalytical Engine.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    19/160

    - 19 -

    Answer a)A computer is a machine for manipulating data according to a list of instructions.

    Computers take many physical forms. Early electronic computers were the size of a room, consuming as much power as several hundred modern personal computers.[1] Today,computers can be made small enough to fit into a wrist watch and be powered from a battery. Society has come to recognize personal computers and their portable equivalelaptop computer, as icons of the information age; they are what most people think of computer". However, the most common form of computer in use today is by far embedded computer. Embedded computers are small, simple devices that are often uscontrol other devicesfor example, they may be found in machines ranging from figaircraft to industrial robots, digital cameras, and even children's toys.

    Answer b)

    A computer is a machine for manipulating data according to a list of instructions.

    Computers take many physical forms. Early electronic computers were the size of a

    room, consuming as much power as several hundred modern personal computers.[1] Today,

    computers can be made small enough to fit into a wrist watch and be powered from a

    battery. Society has come to recognize personal computers and their portable equivale

    laptop computer, as icons of the information age; they are what most people think of

    computer". However, the most common form of computer in use today is by far

    embedded computer. Embedded computers are small, simple devices that are often us

    control other devicesfor example, they may be found in machines ranging from fig

    aircraft to industrial robots, digital cameras, and even children's toys.

    The ability to store and execute programs makes computers extremely versatile

    distinguishes them from calculators. The ChurchTuring thesis is a mathematical state

    of this versatility: Any computer with a certain minimum capability is, in principle, ca

    of performing the same tasks that any other computer can perform. Therefore, comp

    with capability and complexity ranging from that of a personal digital assistant

    supercomputer are all able to perform the same computational tasks as long as time

    storage capacity are not considerations.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    20/160

    - 20 -

    It is difficult to define any one device as the earliest computer. The very definitio

    a computer has changed and it is therefore impossible to identify the first computer. M

    devices once called "computers" would no longer qualify as such by today's stand

    Originally, the term "computer" referred to a person who performed numerical calculatihuman computer), often with the aid of a mechanical calculating device. Examples of

    mechanical computing devices included the abacus, the slide rule and arguably the astr

    and the Antikythera mechanism (which dates from about 150-100 BC). The end o

    Middle Ages saw a re-invigoration of European mathematics and engineering, and Wi

    Schickard's 1623 device was the first of a number of mechanical calculators construct

    European engineers.

    However, none of those devices fit the modern definition of a computer because

    could not be programmed. In 1801, Joseph Marie Jacquard made an improvement to

    textile loom that used a series of punched paper cards as a template to allow his loo

    weave intricate patterns automatically. The resulting Jacquard loom was an important s

    the development of computers because the use of punched cards to define woven patter

    be viewed as an early, albeit limited, form of programmability.

    In 1837, Charles Babbage was the first to conceptualize and design a fu

    programmable mechanical computer that he called "The Analytical Engine".[2] Due to limited

    finance, and an inability to resist tinkering with the design, Babbage never actually bu

    Analytical Engine.

    Question 2:

    a) Write a word document of 10 sentences. b) Make font of the heading center aligned Lucida Handwriting of size 1 4.c) Make the rest of the text justified.d) Make size and font of the rest of the text 11 and Courier New respectively.e) Display the text in two columns.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    21/160

    - 21 -

    Answer a)

    Computer A computer is a machine for manipulating data according to a list of instructions.

    Computers take many physical forms. Early electronic computers were the size of a largroom, consuming as much power as several hundred modern personal computers. Todaycomputers can be made small enough to fit into a wrist watch and be powered from a wa battery. Society has come to recognize personal computers and their portable equivalentlaptop computer, as icons of the information age; they are what most people think of as computer". However, the most common form of computer in use today is by far theembedded computer. Embedded computers are small, simple devices that are often usedcontrol other devicesfor example; they may be found in machines ranging from fighter aircraft to industrial robots, digital cameras, and even children's toys. The ability to storexecute programs makes computers extremely versatile and distinguishes them fromcalculators. The ChurchTuring thesis is a mathematical statement of this versatility: Ancomputer with a certain minimum capability is, in principle, capable of performing the stasks that any other computer can perform. Therefore, computers with capability andcomplexity ranging from that of a personal digital assistant to a supercomputer are all ab perform the same computational tasks as long as time and storage capacity are notconsiderations. Answer b and c)

    Computer A computer is a machine for manipulating data according to a list of instruction

    Computers take many physical forms. Early electronic computers were the size of a room, consuming as much power as several hundred modern personal computers.Tocomputers can be made small enough to fit into a wrist watch and be powered from a w battery. Society has come to recognize personal computers and their portable equivalelaptop computer, as icons of the information age; they are what most people think of computer". However, the most common form of computer in use today is by far embedded computer. Embedded computers are small, simple devices that are often uscontrol other devicesfor example, they may be found in machines ranging from figaircraft to industrial robots, digital cameras, and even children's toys.

    The ability to store and execute programs makes computers extremely versatile distinguishes them from calculators. The ChurchTuring thesis is a mathematical stateof this versatility: Any computer with a certain minimum capability is, in principle, caof performing the same tasks that any other computer can perform. Therefore, compwith capability and complexity ranging from that of a personal digital assistant supercomputer are all able to perform the same computational tasks as long as timestorage capacity are not considerations.

    Answer d)

    Computer

  • 8/6/2019 Part II Software Assignment - Sutirtha

    22/160

    22

    A computer is a machine for manipulating data according to a list ofinstructions. Computers take many physical forms. Early electroniccomputers were the size of a large room, consuming as much power asseveral hundred modern personal computers. Today, computers can bemade small enough to fit into a wrist watch and be powered from awatch battery. Society has come to recognize personal computers andtheir portable equivalent, the laptop computer, as icons of theinformation age; they are what most people think of as "a computer".However, the most common form of computer in use today is by far theembedded computer. Embedded computers ar e small, simple devices thatare often used to control other devices for example, they may befound in machines ranging from fighter aircraft to industrialrobots, digital cameras, and even children's toys.

    The ability to store and execute programs makes computers extremelyversatile and distinguishes them from calculators. The Church Turingthesis is a mathematical statement of this versatility: Any computerwith a certain minimum capability is, in principle, capable ofperforming the same tasks that any other computer can perform.Therefore, computers with capability and complexity ranging fromthat of a personal digital assistant to a supercomputer are all ableto perform the same computational tasks as long as time and storagecapacity are not considerations.

    Answer e)

    Computer A computer is a machine formanipulating data according toa list of instructions.Computers take many physical

    forms. Early electroniccomputers were the size of alarge room, consuming as muchpower as several hundred modernpersonal computers. Today,computers can be made smallenough to fit into a wristwatch and be powered from awatch battery. Society has cometo recognize personal computersand their portable equivalent,the laptop computer, as i consof the information age; they

    are what most people think ofas "a computer". However, themost common form of computer inuse today is by far theembedded computer. Embeddedcomputers are small, simpledevices that are often used tocontrol other devicesforexample; they may be found inmachines ranging from fighter

    aircraft to industrial robots,digital cameras, and evenchildren's toys.

    The ability to store andexecute programs makescomputers extremely versatileand distinguishes them fromcalculators. The ChurchTuringthesis is a mathematicalstatement of this versatility:Any computer with a certainminimum capability is, inprinciple, capable ofperforming the same tasks thatany other computer can perform.Therefore, computers with

    capability and complexityranging from that of a personaldigital assistant to asupercomputer are all able toperform the same computationaltasks as long as time andstorage capacity are notconsiderations.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    23/160

    23

    MICROSOFT EXCEL

    Introduction to Microsoft Excel:

    Excel is an electronic spreadsheet. An electronic spreadsheet is a software programorganizes data in cells. The data stored in different cells automatically updated in case of any care made to the related cells.

    For example, we can store the marks of 40 students and their total in a spreadsheet. Imarks stored in any of the cells are changed, the total value will automatically be updated spreadsheet. This feature of spreadsheet makes it very easy to maintain large business data sheecomplex calculations. Except MS-Excel some other electronic spreadsheet products are: VisLotus 1-2-3 etc.

    Excel was originally written for the Apple Macintosh System in 1984-85. It was thespreadsheet to use a graphical interface with pull down menus and a point and click capabilitymouse. The Excel spreadsheet with a graphical user interface was easier for most people to uthe command line interface of PC-DOS spreadsheet products. When Microsoft launched WiOS, Excel was one of the first application released for it. When Windows gained wide accewith version 3.0 in late 1989 Excel was Microsofts main product. It includes three componworksheets, graph and database management. The calculations are done with more edge in worIf any information is changed the worksheet the program automatically recalculate or rearrandata. The worksheet program can also display the result in the form of different graphs.

    Uses of MS-Excel:

    MS Excel can be used in some of the following areas :--y Budgetsy Payrollsy Inventory controlsy Scientific calculationsy Cost effective analysis

    Features of MS Excel:1. Manipulating data.2. The results are accurate.3. Graphs.4. Information entered can be viewed in a different format.

    Aspreadsheet is a rectangular table (or grid) of information, often financial information. Tword came from "spread" in its sense of a newspaper or magazine item (text and/or graphiccovers two facing pages, extending across the center fold and treating the two pages as one larThe compound word "spread-sheet" came to mean the format used to present bookkeeping ledwith columns for categories of expenditures across the top, invoices listed down the left marg

    the amount of each payment in the cell where its row and column intersectwhich were traditioa "spread" across facing pages of a bound ledger (book for keeping accounting records) oversized sheets of paper ruled into rows and columns in that format and approximately twice as ordinary paper.

    So let's get started digging into what makes a spreadsheet work. Spreadsheets are made up of y columnsy rowsy and their intersections are called cells

  • 8/6/2019 Part II Software Assignment - Sutirtha

    24/160

    24

    In each cell there may be the following types of data

    y text (labels)y number data (constants)y formulas (mathematical equations that do all the work).

    Constants are entries that have a specific fixed value. If someone asks you how old you are,would answer with a specific answer. Sure, other people will have different answers.Formulas are entries that have an equation that calculates the value to display. We DO NOT in the numbers we are looking for; we type in the equation. This equation will be updatedthe change or entry of any data that is referenced in the equation.

    In our first example, the solution was$252.61. This was NOT typed into the keyboard. The formulathat was typed into the spreadsheet was:=PMT(C4/12,C5,-C3)

    C4 (annual interest rate) was divided by 12 because there are 12 months in a year. Dividing by give us the interest rate for the payment period - in this case a payment period of one month.

    It is also important to type in the reference to the constants instead of the constants. Had I e=PMT(.096,60,-12000) my formula would only work for that particular set of data. I could chamonths above and the payment would not change. Remember to enter the cell where the data iand NOT the data itself.

    Spreadsheets have many Math functions built into them. Of the most basic operations are the smultiply, divide, add and subtract. These operations follow the order of operations (just like alLet's look at some examples.

    For these following examples lets consider the following data:y A1 (column A, row 1) =

    5y A2 (column A, row 2) =

    7y A3 (column A, row 3) =8

    y B1 (column B, row 1) =3

    y B2 (column B, row 2) =4

    y B3 (column B, row 3) =6

    A B 1 5 3 2 7 4 3 8 6

    Operation Symbol ConstantData ReferencedData Answer Multiplication * = 5 * 6 = A1 * B3 30 Division / = 8 / 4 = A3 / B2 2 Addition + = 4 + 7 = B2 + A2 11 Subtraction - = 8 - 3 = A3 - B1 5

  • 8/6/2019 Part II Software Assignment - Sutirtha

    25/160

    25

    Spreadsheet Basics:

    Excel allows you to create spreadsheets much like paper ledgers that can perform autocalculations. Each Excel file is aworkbook that can hold manyworksheets . The worksheet is a gridof columns (designated by letters) androws (designated by numbers). The letters and numbers of thecolumns and rows (calledlabels ) are displayed in gray buttons across the top and left side of thworksheet. The intersection of a column and a row is called acell . Each cell on the spreadsheet has acell address that is the column letter and the row number. Cells can contain either text, numbermathematical formulas.

    The worksheets in a workbook are accessible by clicking the worksheet tabs just above the staBy default, three worksheets are included in each workbook. To add a sheet, selectInsertWorksheet

    from the menu bar. To rename the worksheet tab, right-click on the tab with the mouse and Rename from the shortcut menu. Type the new name and press theENTER key.

    The Standard Toolbar

    This toolbar is located just below the menu bar at the top of the screen and allows you to qaccess basic Excel commands.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    26/160

    26

    New - SelectFile|New from the menu bar, pressCTRL+N , or click theNew button to create a newworkbook.

    Open - ClickFile|Open from the menu bar, pressCTRL+O , or click theOpen folder button to openan existing workbook.

    Save - The first time you save a workbook, selectFile|Save As and name the file. After the file isnamed clickFile|Save , CTRL+S , or the Save button on the standard toolbar.

    Print - Click the Print button to print the worksheet.

    Print Preview - This feature will allow you to preview the worksheet before it prints.

    Spell Check - Use the spell checker to correct spelling errors on the worksheet.

    Cut, Copy, Paste, and Format Painter - These actions are explained in the Modifying A Worksheetsection.

    Undo and Redo - Click the backwardUndo arrow to cancel the last action you performed, whether it be entering data into a cell, formatting a cell, entering a function, etc. Click the forwardRedo arrowto cancel the undo action.

    Insert Hyperlink - To insert a hyperlink to a web site on the Internet, type the text into a cell ywant to be the link that can be clicked with the mouse. Then, click the Insert Hyperlink buttenter the web address you want the text to link to and clickOK .

    Autosum, Function Wizard, and Sorting - These features are discussed in detail in the Functionstutorial.

    Zoom - To change the size that the worksheet appears on the screen, choose adifferent percefrom the Zoom menu.

    SUM FUNCTION:

    Probably the most popular function in any spreadsheet is the SUM function. The Sum functioall of the values in each of the specified cells and totals their values. The syntax is:

    y =SUM(first value, second value, etc)

    In the first and second spots you can enter any of the following (constant, cell, range of cells).

    y Blank cells will return a value of zero to be added to the total.y Text cells cannot be added to a number and will produce an error.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    27/160

    27

    Lets use the table here for the discussion that follows:

    We will look at several different specific examples that show how

    the typical function can be used! Notice that in A4 there is a TEXTentry. This has NO numeric value and cannot be included in a total.

    A 1 25 2 50

    3 75 4 test 5

    Example Cells to ADD Answer =sum (A1:A3) A1, A2, A3 150 =sum (A1:A3, 100) A1, A2, A3 and 100 250 =sum (A1+A4) A1, A4 #VALUE! =sum (A1:A2, A5) A1, A2, A5 75

    Average Function : There are many functions built into many spreadsheets. One of the first ones that we are godiscuss is theAverage function. The average function finds the average of the specified dat(S implifies adding all of the indicated cells together and dividing by the total number of cells.) Thesyntax is as follows.

    y =Average (first value, second value, etc.).

    Min Function:

    The next function we will discuss isMin (which stands for minimum). This will return the smallest

    (Min) value in the selected range of cells.y Blank entries are not included in the calculations of the Min Function.y Text entries are not included in the calculations of the Min Function.

    Example of min Cells to look at Ans. min =min (A1:A4) A1, A2, A3, A4 10 =min (A2:A3, 100) A2, A3 and 100 20 =min (A1, A3) A1, A3 10

    =min (A1, A5) A1, A5 (displays the smallestnumber ) 10

    Max Function:

    The next function we will discuss isMax (which stand for Maximum). This will return the largest(max) value in the selected range of cells.

    y Blank entries are not included in the calculations of the Max Function.y Text entries are not included in the calculations of the Max Function

  • 8/6/2019 Part II Software Assignment - Sutirtha

    28/160

    28

    Example of Max Cells to look at Ans. Max =max (A1:A4) A1, A2, A3, A4 30 =max (A1:A4, 100) A1, A2, A3, A4 and 100 100 =max (A1, A3) A1, A3 30

    =max (A1, A5) A1, A5 10 Count Function:

    The next function we will discuss isCount . This will return the number of entries (actually countseach cell that contains number data) in the selected range of cells.

    y Blank entries are not counted.y Text entries are NOT counted.

    Example of Count Cells to look at Answer =Count (A1:A3) A1, A2, A3 3 =Count (A1:A3,100) A1, A2, A3 and 100 4

    =Count (A1, A3) A1, A3 2 =Count (A1, A4) A1, A4 1 =Count (A1, A5) A1, A5 1

    IF Function:

    The next function we will discuss isIF . The IF function will check the logical condition of astatement and return one value if true and a different value if false. The syntax is

    y =IF (condition, value-if-true, value-if-false)

    y value returned may be either a number or texty if value returned is text, it must be in quotes

    Example of IF typed into column B Compares Answer

    =IF (A2>1,"Yes","No") is ( .95 > 1) No =IF (A3>1, "Yes", "No") is (1.37 > 1) Yes =IF (A5>10000, .08, .05) is (14000 > 10000) .08 =IF (A6>10000, .08, .05) is (8453 > 10000) .05

  • 8/6/2019 Part II Software Assignment - Sutirtha

    29/160

    29

    Examples:

    Question 1)

    Create the following worksheet and answer the following questions.

    Compute the following :

    a) Sales figure is expected to grow up by 15% in the year 2006. b) Advertisement cost will increase by 8%.c) Material cost will go up by 11%.d) Labour cost will increase by 15%.e) Overhead will decrease by 5%.

    Calculate the estimated Gross Profit for the year 2006, wherea) Gross Profit = Total sales Total Cost b) Total Cost = Advertisement + Material + Labour + Overhead

    Create a bar graph compareing the expenses of 2005 and 2006.

    Answer :

    Particulars Actuals 2005 (inRs.)

    BUDGETED 2006(inRs.)

    TOTALSALES: 300,000.00 Total Cost: Advertisement 30,000.00 Material 50,000.00 Labour 25,000.00 Overhead 25,000.00 Total Cost: 130,000.00 Gross Profit 170,000.00

  • 8/6/2019 Part II Software Assignment - Sutirtha

    30/160

    30

    Particulars Actuals 2005 (inRs.)

    BUDGETED 2006(inRs.)

    TOTALSALES: 300,000.00 345,000.00 Total Cost: Advertisement 30,000.00 32,400.00 Material 50,000.00 55,500.00 Labour 25,000.00 28,750.00 Overhead 25,000.00 23,750.00 Total Cost: 130,000.00 140,400.00 Gross Profit 170,000.00 204,600.00

    Question 2)

    Create a worksheet having the following fields Employee Name, Basic Salary, HRA, D Net Pay. Insert at least 10 records having employee Name and Basic Salary. Calculate the HRAPF and Net Pay of the employees using appropriate formulas in the worksheet.

    The rules for the calculation are as follows:i) HRA = 15% of Basic Payii) DA = 22% of Basic Pay ( If Basic Salary 8000 and

  • 8/6/2019 Part II Software Assignment - Sutirtha

    31/160

    31

    Answer :

    Employee Name:

    BasicSalary

    Mr. A 8000 Mr. B 20000 Mr. C 7000 Mr. D 8500 Mr. E 15000 Mr. F 6000 Mr. G 17000 Mr. H 25000 Mr. I 33000 Mr. J 12000

    Employee

    Name:

    Basic

    Salary HRA DA PF

    Net

    Pay Mr. A 8000 1200 1760 720 10240 Mr. B 20000 3000 3000 1800 24200 Mr. C 7000 1050 1540 630 8960 Mr. D 8500 1275 1530 765 10540 Mr. E 15000 2250 2250 1350 18150 Mr. F 6000 900 1320 540 7680 Mr. G 17000 2550 2550 1530 20570 Mr. H 25000 3750 3750 2250 30250 Mr. I 33000 4950 4950 2970 39930 Mr. J 12000 1800 2160 1080 14880

    Salary of ABC Corporation

    M r.

    M r. B

    M r. C

    M r. D

    M r. E

    M r. F

    M r. G

    Mr. H

    M r. I

    M r. J

  • 8/6/2019 Part II Software Assignment - Sutirtha

    32/160

    32

    ASSIGNMENT No. 3 Date: 28.10.2009.

    UNIX OPERATING SYSTEM

    Previously UNIX was known as UNICS (Uniplexed Information and Computing Syand was developed by Ken Thompson and Dennis Ritchie at AT&T of Bell Laboratories in 1was developed in C language and found suitable for

    1. Multiuser 2. Multi-terminal3. Multitasking applications

    The 32-bit machines that support multitasking and networking are generally UNIX dThe UNIX system itself supports many operations that are confined to application programs sword processing, screen formatting, terminal-to-terminal communication and even typesetting.

    The UNIX is an excellent tool for programmers for developing programs. However it iuser-friendly. It is ideal for a user who wants to run off-the-shelf application packages. It hacomplex commands which are difficult to remember and tricky to work with, even by a sophisuser. One can make these commands more English like but the user will have to get assistance

    third party for developing a user-interface program (for example, Uniflex).Basic Features of UNIX Operating System:

    The basic features of UNIX operating system are:1. It is written in high level language C and it is easy to put to different configurations.2. UNIX programming environment is usually rich and productive and allows facility to

    complex program from simpler programs.3. The UNIX uses hierarchical file system which allows easy maintenance and effic

    implementation.4. In UNIX, it is easy to write application programs because it uses consistent format for

    and the byte stream.

    5. It is a multiuser and multi-process system. Hence each user can execute several procsimultaneously.6. The UNIX hides the machine architecture from the user and hence it is easy to write pro

    that run on different hardware implementation.

    Protection of Data in UNIX:

    There is multilevel security system in UNIX which are as follows :(a) First Level- Supply of correct login and password by the user when terminal is switched o(b) Second Level- A directory can be assigned permissions as follows:1. Read Permission- means that the list of filenames stored in the directory is accessible by t

    user.2. Write Permission- means that user can manipulate the files, or user can write or add texinto the file.3. Execute Permission- means that user can pass through the directory for going into th

    subdirectories under it.(c) Third Level- The files in UNIX system can also be given permissions as follows :1. Read Permission- means that user can see the contents of the file only.2. Write Permission- means that user can manipulate the contents of the files.3. Execute Permission- means that user can run the file as per the requirement.It is to be noted that the user may always apply one or more levels of security as shown abo

  • 8/6/2019 Part II Software Assignment - Sutirtha

    33/160

    33

    UNIX COMMANDS:

    1. cat

    cat[options][files]This command reads one or more files and prints them on standard output.

    OPTIONS:-y e print a $ to mark the end of each line .must be used with v.y a suppress messages about nonexistent files.

    Examples :

    Display a file$ cat myfile

    Concatenate two files:$ cat file1 file2 >> file3.dat

    Put the contents of a file into a variable$my_variable=`cat $myfile.txt`

    2. chmodchmod[options]mode filesThis command changes the access mode of one or more files. Only the owner of a fileor a privileged user may change its mode.

    OPTIONS:-y f suppress error message upon failure to change a filess mode .y R recursively descends error arguments while setting modes.

    Examples

    chmod 400 file - Read by owner chmod 040 file - Read by groupchmod 004 file - Read by worldchmod 200 file - Write by owner chmod 020 file - Write by group

    chmod 002 file

    - Write by worldchmod 100 file - execute by owner chmod 010 file - execute by groupchmod 001 file - execute by world

    To combine these just add the numbers together:chmod 444 file - Allow read permission to owner and group and worldchmod 777 file - Allow everyone to read, write, and execute file

  • 8/6/2019 Part II Software Assignment - Sutirtha

    34/160

    34

    3. cp

    cp[options ]file1 file2.

    cp[options]files directory

    This command copies one or more files to the same name under directory. If the destination is aexisting file ,the file is overwritten ;if the destination is an existing directory ,the file is copied idirectory.

    OPTIONS:-

    y i prompt for confirmation (y for yes) before overwriting an existing file .y p preserve the modification time and permission modes for the copied file.(norma

    cp submits the permissionof the invoking user).

    Example - copy home directory to floppy

    $ cp -f /mnt/floppy/* /home/simon

    4. echo

    echo[-n][string]

    this is the /bin/echo command.echo arguments to standard output .

    VERSION DIFFERENCES ARE:-

    . /bin/echo

    . /user/ucb/echo.

    . bourne shell echo.

    . c shell echo.

    . korn shell echo.

    5. exprexpr arg1 operator arg2[operator arg3]

    This command evaluates arguments as expressions and prints the results. It is typicused in shell commands to perform a simple mathematics, such as addition or subtraction.

    ARITHMETIC OPERATORS:-

    . +

    .

    . /

    . *

    . %

  • 8/6/2019 Part II Software Assignment - Sutirtha

    35/160

    35

    RELATIONAL OPERATORS:-

    . =. !=. >. >=. bexpr index abcdef cz=> 3expr index index aerror--> expr: syntax errorexpr index quote index a

    => 0

    6. grep

    grep[options] regexp[files]This command searches one or more files for lines that match a regular expression [ regexp ]. Estatus is 0 if any line match, 1 if not, and 2 for errors.OPTIONS:-

    y b precede each line with its block number .y c print only a count of matched lines.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    36/160

    36

    7 . lsls[options] [names]If no names are given, list the files in the current directory. With one or more names ,the list filecontained in a directory name or that match a file names can include file name met characters.

    OPTIONS:-y a list all the files ,including the normally hidden ones.y b show non printing characters in octal.

    EXAMPLES

    ls - a l

    total 109drwxr-xr-x 18 root root 4096 Jun 9 21:12 ./drwxr-xr-x 18 root root 4096 Jun 9 21:12 ../drwxr-xr-x 2 root root 4096 Jun 9 21:14 bin/drwxr-xr-x 3 root root 1024 Jun 9 20:32 boot/drwxr-xr-x 6 root root 36864 Jul 12 10:26 dev/drwxr-xr-x 34 root root 4096 Jul 12 10:25 etc/drwxr-xr-x 5 root root 4096 Jun 9 21:28 home/drwxr-xr-x 4 root root 4096 Jun 9 21:18 lib/drwxr-xr-x 2 root root 16384 Jun 9 21:01 lost+found/drwxr-xr-x 2 root root 4096 Nov 24 1999 misc/drwxr-xr-x 5 root root 4096 Jun 9 20:32 mnt/drwxr-xr-x 2 root root 4096 Aug 23 1999 opt/dr-xr-xr-x 63 root root 0 Jul 12 11:25 proc/drwx------ 13 root root 4096 Jul 12 01:00 root/drwxr-xr-x 3 root root 4096 Jun 9 21:22 sbin/drwxrwxrwt 9 root root 4096 Jul 12 13:48 tmp/drwxr-xr-x 19 root root 4096 Ju n 9 21:07 usr/drwxr-xr-x 17 root root 4096 Jun 9 21:22 var/

    the first column under long ( -l) is the file type'd' for directory(folder)'f' for file

    # list ALL subdirectoriesls *

    8. man

    man[options] [[sections] subjects]This command displays information from the on-line reference manuals .If you dont specify a,you must supply either a keyword (for -k) or a file (for -f).OPTIONS:-

    y f filesdisplay a on line summary of one or reference files .y k display any header line that contains one of the keywords.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    37/160

    37

    9. mkdir

    mkdir[options] directoriesThis command can create one or more directories. You must have write permission in the pa

    directory in order to create a directory.OPTIONS:-

    y m modeset the access mode for new directories.y p create intervening if they dont exist.

    10. mvmv [options] sources targetThis is a command to move files and directories around on the system or to rename them.

    OPTIONS:-y f force the move ,even if the target files exist, suppress messages about the restricted acc

    modes.y I inquire; prompt for a y (yes) response before overwriting an existing target.

    Exa mples

    Rename the file apple as orange.doc:mv apple orange.doc

    Move orange.doc to the Documents folder:mv orange.doc ~/Documents/orange.doc

    Rename a bunch of file extensionse.g. change *.txt into *.htm

    for f in *.txt; do mv ./"$f" "${f%txt}htm"; done

    `mv' can move only regular files across filesystems.

    11. passwd passwd [options] [user]This command creates or changes a password associated with a user name .Only the owner or privileged user may change the password.

    OPTIONS:-y d delete password ,user is no longer prompted for one.y f force expiration of users password :user must change password in the next login.

    12. rmrm [options] files

  • 8/6/2019 Part II Software Assignment - Sutirtha

    38/160

    38

    This command deletes one or more files .to remove file , you must have written permission in tdirectory that contains the file , but you need not have permission on the file itself.OPTIONS:-

    y f force. Remove write protected files without prompting.y I prompt for y (remove the files) or n (do not remove the file) .overrides -f.

    13. rmdirrmdir [options] directoriesThis command deletes the named directories (the directory itself, not the contents) .Directories deleted from the parent directory and must be empty (if not, rm r can be used instead.).Options:y p remove directories and any inter vening parent directories that become empty as a result

    useful for removing sub directory trees.y s suppress standard error messages caused by p.

    Example

    Before deleting with a wildcard, it's wise to echo the files first:

    $ echo elvis?costello*.mp3

    $ rm elvis?costello*.mp3

    14. shsh [options] [arguments]

    The standard command interpreter (bourn shell) executes commands from a terminal or a file.

    15. vivi [options] files

    This command is a screen oriented text editor; based on ex. Options c,-C,-l, -L,-r,-R and t asame as in ex.

    OPTIONS:-

    -c commandenter vi and execute the given vi command.

    -R Read only mode .Files cant be changed.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    39/160

    39

    Section- II

    Programming through C Language

  • 8/6/2019 Part II Software Assignment - Sutirtha

    40/160

    40

    ASSIGNMENT No. 1 Date: 30.10.2009.

    PROGRAM STATEMENT :Write a C program so that for all integers I,J,K,L from 1 to 10. Find and print all combination oand L such that I+J+K=L and I

  • 8/6/2019 Part II Software Assignment - Sutirtha

    41/160

    41

    PROGRAM CODE :#include#include

    int main(void){

    int i,j,k,l,n;

    printf("\nAll combinations of integers i,j,k,l such that i+j+k=l and i

  • 8/6/2019 Part II Software Assignment - Sutirtha

    42/160

    42

    ASSIGNMENT No. 2 Date: 04.11.2009.

    PROGRAM STATEMENT :Write a program, which will ask to enter two set of integers. Then perform the followinoperations:

    a. Intersection. b. Union.c. Minus.

    THEORY:

    A set is a well-defined collection of distinct objects which are called members of the set elements of the set. By well-defined, we mean that it must be possible to tell beyond doubt or not a given object belongs to the collection that we are considering. The elements or membeset can be anything: numbers, people, letters of the alphabet, other sets, and so on. Setconventionally denoted with capital letters. Sets A and B are equal if and only if they have preciselythe same elements. For example, if the set A consists of the elements 1, 2, 3 and 4, then we ethe set as A = {1, 2, 3, 4}.

    The three basic set operations are:a. Union The union of two sets A and B is a new set consisting of the elements which bto A or B or to both. The union of A and B is denoted by AUB. For example, if A = {a,and B = {c, d, e, f}, then AUB = {a, b, c, d, e, f}.

    b. Intersection - The intersection of two sets A and B is a new set consisting of the elemwhich belong to A as well as in B. The intersection of A and B is denoted by A B.example, if A = {a, b, c} and B = {c, d, e, f}, then A B = {c}.

    c. Minus The difference or minus of two sets A and B in that order is the set of elemwhich belong to A but do not belong to B and is denoted by A-B or A\B. For example, i{a, b, c} and B = {c, d, e, f}, then A-B = {a, b}.

    We now implement the above three set operations by the algorithm given below.

    ALGORITHM :Function isort(X,k)(* This function inserts a new element in sorted order in a previously sorted set X. This funccalled every time when a new element is inserted in a set X. At beginning, the new element is iat the end of sorted set. The position of the new element is k. *)S tep 1: [Hold new element in a temporary variable]temp=X[k].S tep 2: [Move ith element to ( i+1)th position till the actual position of temp is found]for i=k-1 down to 1

    if temp

  • 8/6/2019 Part II Software Assignment - Sutirtha

    43/160

    43

    n1, n2 are number of elements in set A and set B*)S tep 1: [Initialise number of elements of three solution sets to zero]n3=n4=n5=0.S tep 2: [Find union, intersection, and minus sets]for i=1 to n1 AND j=1 to n2

    if A[i]

  • 8/6/2019 Part II Software Assignment - Sutirtha

    44/160

  • 8/6/2019 Part II Software Assignment - Sutirtha

    45/160

    45

    printf("%d, ",minus[i]);printf("}\n");

    getch();return 0;

    }

    /* Function isort inserts a new element in sorted order in a previously sorted set

    */void isort(int x[],int k){

    int i,temp;

    temp=x[k]; /* Store the element k in a temporary variable */

    /* Move ith element to (i+1)th position till the position of temp is found */for (i=k-1;i>=0 && temp

  • 8/6/2019 Part II Software Assignment - Sutirtha

    46/160

    46

    Enter element 3 in set A:3

    Enter element 1 in set B:6

    Enter element 2 in set B:2

    Enter element 3 in set B:4

    Enter element 4 in set B:5

    A={3, 4, 5, }

    B={2, 4, 5, 6, }

    AUB={2, 3, 4, 5, 6, }

    Intersection of set A and B={4, 5, }

    A-B={3, }

    DISCUSSIONS :1. Each element inserted in the arrays a and b are sorted by using insertion sort.2. The two sets are sorted and then the merging algorithm is applied to find the resultant se3. The set operations union, intersection, and minus are very important in set theory and ar

    often used.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    47/160

    47

    ASSIGNMENT No. 3 Date: 11.11.2009.

    PROGRAM STATEMENT :Every even integer greater than 4 can be expressed as the sum of two odd primes, like 6=3+3, 8and so on. Write a program to generate such combinations for all the even integers from 6 to 10

    THEORY: An even number is a number which is divisible by 2. For example, 4,10, 22 are even num

    An odd number is a number which is not divisible by 2. For example 3, 5, 17 are odd numb prime number is a natural number that has exactly two distinct natural number divisors, 1 andFor example 2, 3, 5, 7, 11 are prime numbers. The number 1 is by definition not a prime numbe

    Expressing an even number as a sum of two odd primes is called a Goldbach partition number.For example,

    4 = 2 + 26 = 3 + 38 = 3 + 5

    10 = 7 + 3 or 5 + 512 = 5 + 714 = 3 + 11 or 7 + 7.

    We need to generate such combinations for even integers greater than 4 from range 6 to 100.

    ALGORITHM :Procedure Goldbach(a,b)(* a,b are the starting range and ending range of the integers. *)S tep 1: [Check for validity of a and b]if (a mod 2=1 OR b mod 2=1 OR ab)

    Write Wrong value entered.Stop.

    End if.S tep 2: [Initialise]i=a.S tep 3: [For generating different even numbers within the input range]Repeat steps 3 to step 8 till i

  • 8/6/2019 Part II Software Assignment - Sutirtha

    48/160

    48

    S tep 2: [Find whether x is prime]Repeat steps 2 to 4 till div

  • 8/6/2019 Part II Software Assignment - Sutirtha

    49/160

    49

    return 0;}

    INPUT AND OUTPUT :Program to generate every even integer (greater than 4) as the sum of two odd primes within a crange

    Enter the starting even number (larger than 4):6

    Enter the ending even number:100

    The combinations are:

    6 = 3 + 38 = 3 + 510 = 3 + 712 = 5 + 714 = 3 + 1116 = 3 + 13

    18 = 5 + 1320 = 3 + 1722 = 3 + 1924 = 5 + 1926 = 3 + 2328 = 5 + 2330 = 7 + 2332 = 3 + 2934 = 3 + 3136 = 5 + 3138 = 7 + 3140 = 3 + 3742 = 5 + 3744 = 3 + 4146 = 3 + 4348 = 5 + 4350 = 3 + 4752 = 5 + 4754 = 7 + 4756 = 3 + 5358 = 5 + 5360 = 7 + 5362 = 3 + 5964 = 3 + 6166 = 5 + 6168 = 7 + 6170 = 3 + 6772 = 5 + 6774 = 3 + 7176 = 3 + 7378 = 5 + 7380 = 7 + 7382 = 3 + 7984 = 5 + 7986 = 3 + 8388 = 5 + 83

  • 8/6/2019 Part II Software Assignment - Sutirtha

    50/160

    50

    90 = 7 + 8392 = 3 + 8994 = 5 + 8996 = 7 + 8998 = 19 + 79100 = 3 + 97

    DISCUSSIONS :1. This program has the capability to input the range of even numbers.2. In this program, for each even number, only one combination of sum of odd numbe

    computed. There may be combinations of other odd numbers whose sum equals thenumber.

    3. The program checks for wrong input values and asks the user to enter correct values.4. The sqrt() function is used to compute the square root of x, thus reducing the computat

    time in checking whether a number is prime or not.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    51/160

    51

    ASSIGNMENT No. 4 Date: 18.11.2009.

    PROGRAM STATEMENT :Write a C program to find the perfect numbers up to a certain range.

    THEORY:In mathematics, a perfect number is a positive integer that is the sum of its proper podivisors, that is, the sum of the positive divisors excluding the number itself. Equivalently, a number is a number that is half the sum of all of its positive divisors (including itself). For examis a perfect number because its factors 1, 2, 3 adds up to give 6. But 15 is not a perfect n because its factors 1, 3, 5 on adding does not give 15.

    ALGORITHM :Function IsPerfect( n)(* This function checks whether a number n is perfect. The function returns 1 if the

    number is perfect and 0 otherwise.*)S tep 1: [Initialize]s=0.S tep 2: [Find the sum of the factors of the given number]for i=1 to n/2 do

    if (n mod i = 0) thens=s+i.

    end if.end for.S tep 3: [Check whether the number is perfect and returning accordingly]if (s=n) then

    Return 1.else

    Return 0.

    PROGRAM CODE :#include#include

    /* Function IsPerfect returns 1 if n is a perfect number and 0 otherwise */int IsPerfect(int n){

    int i,s=0;

    for(i=1;i

  • 8/6/2019 Part II Software Assignment - Sutirtha

    52/160

    52

    printf("\nEnter the value of n : ");scanf("%d",&n);

    /* Output */printf("\nPerfect number up to %d :\n",n);for(i=1;i

  • 8/6/2019 Part II Software Assignment - Sutirtha

    53/160

    53

    ASSIGNMENT No. 5 Date: 20.11.2009.

    PROGRAM STATEMENT :Write a menu driven program to find the value of sin(x), cos(x),, log(x).

    THEORY:

    Sin(x) and cos(x) are two basic operations or functions in trigonometry. Here x is the between two sides of a right angled triangle. It is not practical to get the values of different sidright angled triangle. So, it is not possible to calculate the values of these basic operations easthis reason, we need other computational method to calculate these values. We use De-Motheorem to calculate these basic operations or functions.From De-Moivres theorem we get,

    wherei= (1).Again, from exponential series,

    (2)

    Using (1) and (2), we can write, (3) (4)Here the angleis in radian unit. We know the relation between degree and radian units as follow (5) Now, using (3) and (4) along with (5), it is possible to calculate the value of these boperations.

    and log(x) are two very important infinite series in mathematics, called the exponeseries and the logarithmic series, which are defined as follows.For all values of x the infinite series is convergent and its sum to infinity isdenoted by . (6)If -1

  • 8/6/2019 Part II Software Assignment - Sutirtha

    54/160

    54

    For By observation we get,

    for i 1, and . Now, .

    For By observation we get,

    for i 1, and .

    Now, .

    For By observation we get,

    For log(x)By observation we get,

    Now, the algorithm for calculating the different functions is given below. is the error uwhich terms will be added.

    Function sine(x)(* This function returns the sine of x. Here x is in radian unit *)S tep 1: [Initialisation]sine=x, i=1, term=x.S tep 2: [Apply the formula iteratively]while (|term|>)

    term=-(term*x*x)/((2i+1)*(2i)).

  • 8/6/2019 Part II Software Assignment - Sutirtha

    55/160

    55

    sine=sine+term.i=i+1.

    End while.S tep 3: [Finished]Return sine.

    Function cosine(x)(* This function returns the cosine of x. Here x is in radian unit *)S tep 1: [Initialisation]cosine=1, i=0, term=1.S tep 2: [Apply the formula iteratively]while (|term|>)

    term=-(term*x*x)/((2i+1)*(2i+2)).cosine=cosine+term.i=i+1.

    End while.S tep 3: [Finished]Return cosine.

    Function expo(x)(* This function returns the exponential value of x *)S tep 1: [Initialisation]e=1, i=1, term=1.S tep 2: [Apply the formula iteratively]while (|term|>)

    term=(term*x)/i.e=e+term.i=i+1.

    End while.S tep 3: [Finished]Return e.

    Function logarithmic(x)S tep 1: [Initialisation]log=x-1, i=0, term=x-1.S tep 2: [Apply the formula iteratively]while (|term|>)

    term=-(term*(i+1)*(x-1))/(i+2).log=log+term.i=i+1.

    End while.S tep 3: [Finished]Return log.

    PROGRAM CODE :#include#include#include#define DIFF 0.0000001

    double sine(double x);double cosine(double x);double expo(double x);double logarithmic(double x);

    int main(void)

  • 8/6/2019 Part II Software Assignment - Sutirtha

    56/160

    56

    {int n; double x;

    printf("\t*** Program to find the value of sin(x), cos(x), e^(x), log(x)***\n");

    do{

    printf("\n1.Find sin(x)\n2.Find cos(x)\n3.Find e^(x)\n4.Findlog(x)\n5.Exit\n");printf("\nEnter your choice:");scanf("%d",&n);

    if (n==5)break;

    /* Check for wrong value of n */if (n>5 || n=DIFF;i++){

    term=-(term*x*x)/((2*i+1)*2*i); /* Calculate next term */sine=sine+term; /* Add new term to sine */

  • 8/6/2019 Part II Software Assignment - Sutirtha

    57/160

    57

    }return sine;

    }

    double cosine(double x){

    double term,cosine;int i;

    x=x*M_PI/180; /* Convert x to radian */

    term=1.0; /* 1st term is calculated */cosine=term; /* 1st term is added to cosine */

    /* Continue adding successive terms greater than DIFF */for (i=0;fabs(term)>=DIFF;i++){

    term=-(term*x*x)/((2*i+1)*(2*i+2)); /* Calculate next term */cosine=cosine+term; /* Add new term to cosine */

    }return cosine;

    }

    double expo(double x)

    { double term,e;int i;

    term=1.0; /* 1st term is calculated */e=term; /* 1st term is added to e */

    for (i=1;fabs(term)>=DIFF;i++){

    term=(term*x)/i; /* Calculate next term */e=e+term; /* Add new term to e */

    }return e;

    }

    double logarithmic(double x)

    { double term,log;int i;

    term=x-1; /* 1st term is calculated */log=term; /* 1st term is added to log */

    /* Continue adding successive terms greater than DIFF */for (i=0;fabs(term)>=DIFF;i++){

    term=-(term*(i+1)*(x-1))/(i+2); /* Calculate next term */log=log+term; /* Add new term to log */

    }return log;

    }

    INPUT AND OUTPUT : *** Program to find the value of sin(x), cos(x), e^(x), log(x) ***

    1.Find sin(x)2.Find cos(x)3.Find e^(x)4.Find log(x)5.Exit

  • 8/6/2019 Part II Software Assignment - Sutirtha

    58/160

    58

    Enter your choice:1

    Enter the value of x in degrees:30

    The value of sin(30.000000) is 0.500000

    1.Find sin(x)2.Find cos(x)3.Find e^(x)4.Find log(x)5.Exit

    Enter your choice:2

    Enter the value of x in degrees:60

    The value of cos(60.000000) is 0.500000

    1.Find sin(x)2.Find cos(x)3.Find e^(x)4.Find log(x)5.Exit

    Enter your choice:3

    Enter the value of x:1

    The value of e^(1.000000) is 2.718282

    1.Find sin(x)

    2.Find cos(x)3.Find e^(x)4.Find log(x)5.Exit

    Enter your choice:4

    Enter the value of x(0

  • 8/6/2019 Part II Software Assignment - Sutirtha

    59/160

    59

    DISCUSSIONS :1. The logarithmic function can compute logarithmic values of x only in the range [0

  • 8/6/2019 Part II Software Assignment - Sutirtha

    60/160

    60

    ASSIGNMENT No. 6 Date: 25.11.2009.

    PROGRAM STATEMENT :Write a C program to find the saddle point in a given matrix.

    THEORY:

    In mathematics, a matrix is a rectangular array of numbers. An item in a matrix is callentry or an element.

    A saddle point in a matrix is the position, the value of which is the smallest in its rowmaximum in its column. That is, in a matrix A, the point (m, n) is the saddle point if A(m, n)smallest element of the mth row and greatest element of the nth column. There can be more than onesaddle point in a matrix.

    ALGORITHM :Function saddlepoint(A, x, y, r, c)(* This function checks whether a point (x, y) is a saddle point in matrix A. It returns 1 if (x, y)saddle point and 0 otherwise. r is the number of rows and c is the number of columns in the ma

    *)S tep1: [Initialize]min=max=A[x][y], p=1.S tep 2: [Check if it is the minimum element in its row]for i=1 to c do

    if A[x][i]max p=0.

    End if.End for.S tep 4: [Finished]Return p.

    PROGRAM CODE :#include#include

    int check_saddle(int[20][20],int,int,int,int);

    int main(void){

    int a[20][20],i,j,x,r,c,flag=0;

    printf("\t\t*** Program to find saddle point of a matrix ***\n");

    /* INPUT VALUES */printf("\nEnter the number of rows in the matrix: ");scanf("%d",&r);printf("\nEnter the number of columns in the matrix: ");scanf("%d",&c);printf("\nEnter each element:");for(i=0;i

  • 8/6/2019 Part II Software Assignment - Sutirtha

    61/160

    61

    printf("\nElement (%d,%d) : ",i+1,j+1);scanf("%d",&a[i][j]);

    }/* PRINTING ORIGINAL MATRIX */printf("\nOriginal matrix : \n");for(i=0;i

  • 8/6/2019 Part II Software Assignment - Sutirtha

    62/160

    62

    Element (1,2) : 2

    Element (1,3) : 3

    Element (2,1) : 2

    Element (2,2) : 1

    Element (2,3) : 4

    Original matrix :0 2 32 1 4

    There is no saddle point for the matrix!

    Run 2:*** Program to find saddle point of a matrix ***

    Enter the number of rows in the matrix: 3Enter the number of columns in the matrix: 3

    Enter each element:Element (1,1) : 2Element (1,2) : 1Element (1,3) : 3Element (2,1) : -1Element (2,2) : 0

    Element (2,3) : 1Element (3,1) : 3Element (3,2) : -1Element (3,3) : 4

    Original matrix :2 1 3-1 0 13 -1 4

    Saddle point = 1 at position (1,2)

    DISCUSSIONS :1. There can be more than one saddle point in a matrix. The program is capable to find a

    saddle points in a given matrix.2. Saddle point does not exist in all matrices.3. If (m, n) be the saddle point of a matrix A, then (m, n) will not be the saddle poin

    AT.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    63/160

    63

    ASSIGNMENT No. 7 Date: 2 7 .11.2009.

    PROGRAM STATEMENT :Write a program to check if a square matrix is Skew-Symmetric.

    THEORY:

    In mathematics, a matrix is a rectangular array of numbers. An item in a matrix is callentry or an element. A square matrix is a matrix which has the same number of rows and column-by-n matrix is known as a square matrix of order n.

    A square matrix A is said to be skew-symmetric, if its transpose be equal to its negativeif . Hence the matrix is skew-symmetric, if for all i and j. The diagonal

    elements of a skew-symmetric matrix are thus obviously 0. For example, is a skew-symmetric matrix. ALGORITHM :

    Function Skew(A,n)(* This function returns 1 if the input matrix is skew-symmetric and 0 otherwise.A is the input matrix.n is the order of input matrix.

    *)S tep 1: [Check for skew-symmetric condition]for i=1 to n do

    for j=i to n doif a[i][j]!=-a[j][i]

    Return 0.End if.

    End inner for.End outer for.S tep 2: [Finished]Return 1.

    PROGRAM CODE :#include#include

    int skew(float [50][50], int);

    int main(void){

    int i,j,n,x; float a[50][50];

    printf("*** Program to check whether a square matrix is skew -symmetric ***\n");

    /* Input order of matrix n and check for validity of n */do{

    printf("\nEnter the order of the square matrix:");scanf("%d",&n);if (n

  • 8/6/2019 Part II Software Assignment - Sutirtha

    64/160

    64

    for (j=i;j

  • 8/6/2019 Part II Software Assignment - Sutirtha

    65/160

    65

    Enter the order of the square matrix:3

    Enter element in matrix in position(1,1):0

    Enter element in matrix in position(1,2):-1

    Enter element in matrix in position(1,3):2

    Enter element in matrix in position(2,1):1

    Enter element in matrix in position(2,2):0

    Enter element in matrix in position(2,3):-3

    Enter element in matrix in position(3,1):-2

    Enter element in matrix in position(3,2):3

    Enter element in matrix in position(3,3):0The square matrix is skew-symmetric.

    DISCUSSIONS :1. In this program we traverse only half of the input matrix. For the non-diagonal and dia

    elements we check whether condition satisfies and thus the non-diagonal elementsare also accessed by the same for loop.

    2. By checking only one half of the matrix, the no. of comparisons of the above algorithmorder of .5 .

    3. A separate function skew is used to check whether the given input matrix is skew-symm

    or not. The main function is only used to take inputs and show the output.

  • 8/6/2019 Part II Software Assignment - Sutirtha

    66/160

    66

    ASSIGNMENT No. 8 Date: 04.12.2009.

    PROGRAM STATEMENT :Write a program to implement matrix multiplication of chain of matrices.

    THEORY:

    In mathematics, a matrix is a rectangular array of numbers. An item in a matrix is callentry or an element. If m, n numbers are arranged in a rectangular array of m rows and n columcalled a matrix of order mXn.

    The product AB of two matrices A and B exists if the number of columns in A is equal number of rows in B and the matrices A and B are said to be conformable for the product A= and B= matrices then the number of columns (p) of A equals the number of row(p) of B. Hence the product AB is defined. The product AB is of order mXn and each of its elis given by:

    If many matrices are multiplied together, and their dimensions are written in a list in o

    e.g.m n, n p, p q, q r , the size of the result is given by the first and the last numbers (m r ), and thevalues surrounding each comma must match for the result to be defined. The ordinary matrix is not commutative.

    ALGORITHM :Function MatMult(A,B,C,p,q,r)(* This function multiplies two matrices A and B and store it in another matrix C. Size of A is (and size of B is (q X r) *)S tep 1: [Initialize]i=j=k=0.S tep 2: [Multiply]for i=1 to p do

    for j=1 to r doC[i][j]=0.for k=1 to q do

    C[i][j]=C[i][j]+(A[i][k]XB[k][j]).End for.

    End for.End for.S tep 3: [Finished]Return.

    Function ChainMatMult(M,n)(* This function implements chain of matrix multiplication. It returns the final matrix.

    M is the array of matrices.n is the number of matrices .

    *)S tep 1: [Check if there is only