CITL-001

Page 1

Install Your Operating System (WINDOWS/LINUX)

UNIT 1 INSTALL YOUR OPERATING SYSTEM (WINDOWS/LINUX) Structure

Page Nos.

1.0

Introduction

5

1.1

Objectives

6

1.2

Windows Operating System

6

1.2.1

Features of Windows Operating System

8

1.2.2

Windows Installing Procedure (Windows XP)

8

1.2.3

Basic Utilities for Windows

1.3

20

Linux Operating System

22

1.3.1

Features of Linux Operating System

23

1.3.2

How to Install Linux Operating System (Fedora 9)

24

1.3.3

Linux Utilities and Basic Commands

34

1.4

Summary

39

1.5

Solutions/Answers

40

1.6

References/Further Readings

41

1.0 INTRODUCTION In this unit, we are going to explore the practical process related to the loading and installing of Proprietary and Open Source operating system, so far as the Proprietary operating system is concerned we are going to discuss for Windows XP and on the end of Open source operating system we are going to work with Fedora. Before beginning the actual technicalities, Let us discuss some fundamentals of operating system. Learners, after going through the study material of other courses of our CIT programme, you might have learned that the term Software, which is broadly classified into two categories i.e., Application Software and System Software, however you may come across various terminologies related to the types of software like; Shareware, Freewares, Middlewares, Device Drivers, Linkers, Loaders, parsers, assemblers etc., but soon you will be able to identify that these are either the sub categories of our Application Software or System Softwares. As this unit is explicitly about the operating system, so, we will restrict our discussion to this term only. An Operating System (commonly abbreviated to either OS or O/S) is a System Software whose job is to act as an interface between computer hardware and user. OS is responsible for the management and coordination of activities and the sharing of the limited resources of the computer. The operating system acts as a host for other application software that are suppose to run on the machine (i.e. hardware). As a host, one of the purposes of an operating system is to handle the details of the operation of the hardware.

5


Lab Manual -1

This relieves application programs from having to manage these details and makes it easier to write applications. Almost all computers, including handheld computers, desktop computers, supercomputers, and even video game consoles, use an operating system of some type. Some of the oldest models may however use an embedded operating system, that may be contained on a compact disk or other data storage device. But why to talk of old things, computers is upcoming and dynamic field, today’s mobile phones are nothing but small computers, the O.S. which generally works with our mobile phones is Symbian, Windows Mobile edition of O.S. is also there, and many more are in pipeline. The function of O.S., here and everywhere is to provide. help for running applications on the hardware, which may be your mobile phone, these applications might be developed in various languages like Java, .Net frame work is also in wide usage. Thus, the job of an Operating system is to offer a number of services to the application programs and users. Applications access these services through application programming interfaces (APIs) or system calls. By invoking these interfaces, the application can request a service from the operating system, pass parameters, and receive the results of the operation. Users may also interact with the operating system by using command line interface (CLI), or using a graphical user interface (GUI). Soon, you will come across these interfaces while going through the text of this unit This unit mainly focuses on the installation procedure of both Windows and Linux (Fedora) operating systems. It also covers releases of both the operating systems starting from 1st version to present version and features of both Windows and Linux operating systems.

1.1 OBJECTIVES After going through this unit, you will be able to :

list the features of Windows XP;

know the installation procedure of Windows XP;

know the Utilities of Windows XP;

list the features of Fedora;

know the installation procedure of Fedora; and

know some utilities and basic commands of Linux (Fedora).

1.2 WINDOWS OPERATING SYSTEM The Operating System named Windows is a very successful product of Microsoft’s, a renowned company in the arena of operating systems. It has been around a long time and is used by most people running PCs (personal computers). In 1983, Microsoft announced the development of Windows, a graphical user interface (GUI) for its own 6


operating system (MS-DOS), which was not Graphically enabled, Figure 1 shown below, where c:\> is the DOS prompt, referring to directory C:\. Since then, Microsoft has developed many versions of Windows, and the product line has changed from a GUI product to a modern operating system. How ever you can switch yourself from one mode to other i.e. GUI to Non GUI (i.e.CLI), depending on your choice. Below the installation process of Windows XP is given, once it is loaded, then you can click your mouse on Start menu, go to Run, click in it a window will pop up, in the box simply write cmd and press enter, you will see the DOS prompt as shown below which is the CLI of the GUI i.e. Windows XP loaded by you.

Install Your Operating System (WINDOWS/LINUX)

Figure 1 : DOS Prompt of Windows XP

The first independent version of Microsoft Windows, version 1.0, was released in the year 1985. Since then, Microsoft released different versions of windows (windows 2.0, 3.0, 3.1, windows 95, windows 98 and windows XP) over a period till 2001. Later in the year 2007, Microsoft released Windows Vista. Windows Network Operating System Microsoft released network operating system for servers for various network services. Windows NT 3.1 is the first release of Microsoft's Windows NT line of server in the year 1993. Since then, Microsoft released various versions (Windows NT 4.0, Windows 2000, Windows server 2003 and Windows server 2008) over a period till 2008. You might be thinking when to use the Network O.S. and when to use Other O.S. like Windows XP, the answer is that, when you are supposed to develop software in client server Environment or networked environment then use the Server edition of an O.S. else use other O.S., but generally professional applications are developed on NT or server technologies. 7


Lab Manual -1

1.2.1

Features of Windows Operating System

The following are some of the features of Windows Operating system on latest releases: User Interface & Device Support : Windows has Graphical User Interface (GUI) and also has Command Line Interface (CLI) for interaction and maintenance of the system. It also has fast user switching and remote assistance feature. It provides new and/or improved drivers and user interfaces for devices. Accessibility and Usability : Windows has consistency between it’s versions and applications. It also has application compatibility. Remote Desktop : Users can log into Windows remotely through the Remote Desktop service. It is built on Terminal Services technology, and is similar to "Remote Assistance", but allows remote users to access local resources such as printers. Power Management : Windows has power management feature. It supports multiple levels of sleep states, including critical sleep states when a mobile (or UPS connected) computer is running out of battery power, processor power control, selective suspend of externally attached (such as USB) devices, and turning off the power to the screen of a laptop when the lid is closed. In addition, it also dims the screen when the laptop has low battery power.

1.2.2

Windows Installation Procedure (Windows XP)

Windows XP is a versatile O.S. which took over various laggings in the earlier O.S. given by Microsoft. You will come across these differences when you work with a machine having Windows 98 as an O.S., and then you switch over to a machine loaded with Windows XP as the O.S. One major component which really improves the performance and working is the availability of various device drivers which really make device operation as simple as plug-n-play. However, there are some sacrifices to enjoy such features, i.e., you need to have system i.e., hardware with minimum configurations as given below in Table 1.

If the minimum system requirement is not

fulfilled then you will not be able to install this O.S. on to your machine, however, Windows 98 might serve the purpose. But to work with Windows 98 you need to install drivers of almost all the devices you want to work with and this hinders the plug-n-play features. So, Windows XP is in huge demand globally, let us learn how to load it before making us to work on it.

8


Table 1 : Minimum System Requirements for Windows XP System Requirements

Minimum

Recommended

Processor

233 MHz

300 MHz or higher

Memory

64 MB RAM

128 MB RAM or higher

Video adapter and monitor

Super VGA (800 x 600) or higher resolution

Hard drive disk free space

1.5 GB or higher

Drives

CD-ROM drive or DVD drive

Input devices

Keyboard. Microsoft Mouse or compatible pointing device

Sound

Sound card. Speakers or headphones

Install Your Operating System (WINDOWS/LINUX)

The following step by step procedure will help you to install Windows XP. The installation procedure is shown with the figure appears on your screen after doing a step. 1) Insert the Windows XP CD into your computer and restart. 2) If prompted to start from the CD, press SPACEBAR. If you miss the prompt (it only appears for a few seconds), restart your computer to try again.

3) Windows XP Setup begins. During this portion of setup, your mouse will not work, so you must use the keyboard. On the Welcome to Setup page, press ENTER.

9


Lab Manual -1

4) On the Windows XP Licensing Agreement page, read the licensing agreement. Press the PAGE DOWN key to scroll to the bottom of the agreement. Then press F8.

5) This page enables you to select the hard disk drive on which Windows XP will be installed. Once you complete this step, all data on your hard disk drive will be removed and cannot be recovered. It is extremely important that you have a recent backup copy of your files before continuing. When you have a backup copy, press D, and then press L when prompted. This deletes your existing data. 6) Press ENTER to select Unpartitioned space, which appears by default.

10


7) Press ENTER again to select Format the partition using the NTFS file system, which appears by default.

Install Your Operating System (WINDOWS/LINUX)

8) Windows XP erases your hard disk drive using a process called formatting and then copies the setup files. You can leave your computer and return in 20 to 30 minutes.

9) Windows XP restarts and then continues with the installation process. From this point forward, you can use your mouse. Eventually, the Regional and Language Options page appears. Click Next to accept the default settings. If you are multilingual or prefer a language other than English, you can change language settings after setup is complete. 11


Lab Manual -1

10) On the Personalize Your Software page, type your name and your organization name. Some programs use this information to automatically fill in your name when required. Then, click Next.

12


11) On the Your Product Key page, type your product key as it appears on your Windows XP CD case. The product key is unique for every Windows XP installation. Then, click Next.

Install Your Operating System (WINDOWS/LINUX)

12) On the Computer Name and Administrator Password page, in the Computer name box, type a name that uniquely identifies your computer in your house, such as FAMILYROOM or TOMS. You cannot use spaces or punctuation. If you connect your computer to a network, you will use this computer name to find shared files and printers. Type a strong password that you can remember in the Administrator password box, and then retype it in the Confirm password box. Write the password down and store it in a secure place. Click Next.

13


Lab Manual -1

13) On the Date and Time Settings page, set your computer’s clock. Then, click the Time Zone down arrow, and select your time zone. Click Next.

14) Windows XP will spend about a minute configuring your computer. On the Networking Settings page, click Next.

14


15) On the Workgroup or Computer Domain page, click Next.

Install Your Operating System (WINDOWS/LINUX)

16) Windows XP will spend 20 or 30 minutes configuring your computer and will automatically restart when finished. When the Display Settings dialog appears, click OK.

17) When the Monitor Settings dialog box appears, click OK.

15


Lab Manual -1

18) The final stage of setup begins. On the Welcome to Microsoft Windows page, click Next.

19) On the Help protect your PC page, click Help protect my PC by turning on Automatic Updates now. Then, click Next

20) Windows XP will then check if you are connected to the Internet: • If you are connected to the Internet, select the choice that describes your network connection on the Will this computer connect to the Internet directly, or through a network? page. If you’re not sure, accept the default selection, and click Next. 16


Install Your Operating System (WINDOWS/LINUX)

21)

If you use dial-up Internet access, or if Windows XP cannot connect to the Internet, you can connect to the Internet after setup is complete. On the How will this computer connect to the Internet? page, click Skip.

17


Lab Manual -1

22) Windows XP Setup displays the Ready to activate Windows? page. If you are connected to the Internet, click Yes, and then click Next. If you are not yet connected to the Internet, click No, click Next, and then skip to step 24. After setup is complete, Windows XP will automatically remind you to activate and register your copy of Windows XP.

23) On the Ready to register with Microsoft? page, click Yes, and then click Next.

18


24) On the Collecting Registration Information page, complete the form. Then, click Next.

Install Your Operating System (WINDOWS/LINUX)

25) On the Who will use this computer? page, type the name of each person who will use the computer. You can use first names only, nicknames, or full names. Then click Next. To add users after setup is complete or to specify a password to keep your account private, read Create and customize user accounts.

19


Lab Manual -1

26) On the Thank you! page, click Finish.

Congratulations! Windows XP setup is complete. You can log on by clicking your name on the logon screen. If you’ve installed Windows XP on a new computer or new hard disk drive, you can now use the File and Settings Transfer Wizard to copy your important data to your computer or hard disk drive. Note: Whenever you are working with your computer system do not save your data in to the disk space or drive where your O.S. resides, because if something goes wrong and you need to format your system then your data will be lost. Generally, O.S. is loaded in C: drive, so avoid saving your data in this drive and save it in other partitions. So that your data is safe, even if something goes wrong and you need to format your system.

1.2.3

Basic Utilities for Windows

Windows has a rich set of utilities you can check the details of these in your Windows XP. In this section we have given you few additional. utilities for File Management, Productivity, Security and System maintenance. File Management : WinRAR is a powerful archive manager. It can backup your data and reduce the size of email attachments, decompress RAR, ZIP and other files downloaded from Internet and create new archives in RAR and ZIP file format. FlashGet is a leading download manager and has the highest amount of users on the internet. It uses MHT (Multi-server Hyper-threading Transportation) technique, supports various protocols and has excellent document management features. FlashGet is a freeware without any adware or spyware. 20


Productivity : Paint.NET is free image and photo editing software for computers that run Windows. ThumbsPlus is an image manager that also includes a database system for image organization and cataloging

Install Your Operating System (WINDOWS/LINUX)

Security : Windows has various security tools for Firewall, Antivirus and Antispyware. System Maintenance : The Symantec's Norton Save & Restore, which can create full system and file backups to another drive, either in the background or on demand. Disk Director Suite : It can reorganize a PC for better performance and data protection. It is the easiest and most convenient partition manager and hard disk toolkit. It brings together the most popular disk management functions, partition recovery tools, and boot disk manager. Lab Exercises 1 1) Will you be able to load Windows XP on a machine having 32 MB RAM? …………………………………………………………………………………… …………………………………………………………………………………… …………………………………………………………………………………… 2)

Does the increase in the capacity of hard disk from its minimum requirement to say some upper limit affects the system’s performance? …………………………………………………………………………………… ……………………………………………………………………………………

3)

…………………………………………………………………………………… Does question 2 above means that attaching a hard disk having capacity in terabytes to a system having 64MB RAM and 233MHz processor will not affect the system performance? …………………………………………………………………………………… ……………………………………………………………………………………

4)

If some network application is to be developed then which O.S. you would prefer to work with and why? …………………………………………………………………………………… ……………………………………………………………………………………

5)

…………………………………………………………………………………… Do we have any operating system which makes our Mobile phones to work and run the applications on it , or some different mechanism is there? …………………………………………………………………………………… …………………………………………………………………………………… 21


Lab Manual -1

6)

“Once the GUI of an Windows O.S. is loaded, then also we can work with its CLI ”, if you agree then give the steps involved to switch over from GUI to CLI in say, WindowsXP? …………………………………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

7)

After completing the O.S. Loading process, what have you realized, as to where does our O.S. resides in to the computer system? …………………………………………………………………………………… ……………………………………………………………………………………

8)

…………………………………………………………………………………… In which drive should we save our data, and why? What problem may occur if we try to save data in the partition or memory segment where our O.S. is residing or loaded? …………………………………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

1.3 LINUX OPERATING SYSTEM Linux is a freely available, open source, Unix-like operating system. Written originally for the PC by Linus Torvalds, with the help of many other developers across the Internet, Linux now runs on multiple hardware platforms. Because of its speed, stability, and low cost, Linux became the fastest growing operating system for servers. Today, Linux is widely used for both basic home and office uses. It is the main operating system used for high performance business and in web servers. Linux has made a huge impact in this world. Red Hat Linux The first public release of Red Hat Linux (version 1.0) is dated 1994, after that there are many versions of Red Hat Linux 1.1, 2.0, 2.1, 3.0.3, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2, 6.0, 6.1, 6.2, 7, 7.1, 7.2, 7.3, 8.0 and 9 over a period till the year 2003. After that Redhat and Fedora project were merged. Fedora Fedora is a Linux-based operating system that showcases the latest in free and open source software. Fedora is always free for anyone to use, modify, and distribute. It is built by people across the globe who work together as a community: the Fedora Project. The Fedora Project is open and anyone is welcome to join. 22


Fedora Core 1 was the first version of Fedora and was released in the year 2003. Since, then different versions of Fedora such as Fedora Core 2, 3, 4, 5 and 6 were

Install Your Operating System (WINDOWS/LINUX)

released till 2006. Then new versions such as Fedora 7, 8, 9 and 10 are also released till 2008. The installation procedure for Fedora 9 is explained in this unit.

1.3.1

Features of Linux Operating System

The following are various features of Linux operating system: Low Cost There is no need to spend time and huge amount money to obtain licenses since Linux and much of its software come with the GNU General Public License. There is no need to worry about any software that you use in Linux. Stability Linux has high stability compared with other operating systems. There is no need to reboot the Linux system to maintain performance levels rarely. Its freezes up or slow down. It has a continuous up-times of hundreds of days or more. Performance Linux provides high performance on various networks. It has the ability to handle large numbers of users simultaneously. Networking Linux provides a strong support for network functionality; client and server systems can be easily set up on any computer running Linux. It can perform tasks like network backup more faster than other operating systems. Flexibility Linux is very flexible. Linux can be used for high performance server applications, desktop applications, and embedded systems. You can install only the needed components for a particular use. You can also restrict the use of specific computers. Compatibility It runs all common Unix software packages and can process all common file formats. Fast and Easy Installation Linux distributions come with user-friendly installation. 23


Lab Manual -1

Better use of Hard Disk Linux uses its resources well enough even when the hard disk is almost full. Multitasking Linux is a multitasking operating system. It can handle many things at the same time. Open Source Linux is an Open source operating systems. You can easily get the source code for Linux and edit it to develop your personal operating system.

1.3.2

How to Install Linux Operating System (Fedora 9)

System requirements (minimum)

• • • • •

300 MHz x86 processor 64 MB of system memory (RAM) At least 4 GB of disk space (for full installation and swap space) VGA graphics card capable of 640 × 480 resolution CD-ROM drive or network card

System requirements (recommended)

• • • • • •

700 MHz x86 processor or higher 384 MB of system memory (RAM) or more 8 GB of disk space or more Graphics card capable of 1024×768 resolution Sound card A network or Internet connection

Note: For proper installation keep the size of swap space or swap area, approximately greater than or equal to the double of the size of the RAM of your system, the reason behind requires more in depth understanding of the concepts of O.S., which can’t be discussed at this level. However, the concern is related to the paging and segmentation management when swaps in the memory segments are performed. The following step by step procedure helps the student to install Fedora 9. Similar to Windows XP installation procedure, Step by Step figures are also shown for more clarity. 1) 24

Insert Fedora CD/DVD in optical drive of your computer and boot from it


Then you will get the following Fedora welcome screen. Select “Install or upgrade an existing system” and press enter key. Wait for a while for the system to load…

2)

Install Your Operating System (WINDOWS/LINUX)

Select “Skip” button to start the installation

Then Anaconda (the Fedora installer) will load and you'll see the welcome screen. Click the “Next” button

25


Lab Manual -1

3)

Choose your language

A warning message about the hard drive partitions may appear. If so, click on “Yes” button

4)

Setup your network a)

If you have a DHCP network (dynamic IP address), click on “Next” button, but if you have a static IP address (ask your provider if you're not sure) click on “Edit” button and follow the instructions given below:

b)

If you have an IPv4 address, make sure it's enabled. If you have an IPv6 address, make sure it's enabled too (if you don't have an IPv6 address, uncheck the 'Enable IPv6 support' option).

c)

Check the "Manual configuration" option and enter your IP address and the Netmask, Gateway, primary and secondary DNS as shown in the following screens (ask your provider if you don't know them). Do the same for the IPv6 address (if you have one). Click on “OK” button, once you've finished.

26


Install Your Operating System (WINDOWS/LINUX)

27


Lab Manual -1

5)

Select your location (Country)

Click on “Next” button, once you have done with the network configuration to select your location (country) and time zone.

6)

Enter root password

Click on “next” button to enter the root (System Administrator) password. The longer, the better (WRITE IT SOMEWHERE OR MEMORIZE IT)

7)

Select Disk partition

Here comes the partitioning part! If you have an empty hard drive, all you have to do is click “Next” button (make sure the "Remove all partitions on selected drives and create default layout" option is selected). If you don't have an empty hard drive and you still want to install Fedora 9 on your machine, then make sure you select the "Use free space on the selected drives and create default layout" option (Note: 10 GB minimum of free space is required). Click on “Next” button. 28


Install Your Operating System (WINDOWS/LINUX)

Note: Encryption is supported in this release and you can enable it with a single mouse click, by checking the "Encrypt system" option!

Note: Click the 'Write changes to disk' button when asked

29


Lab Manual -1

The hard disk will be formatted and the partitions will be created

8)

30

Select the desired packages


Install Your Operating System (WINDOWS/LINUX)

9)

Format the partitions and copy the packages into your hard disk

Click on “Next� button and everything will be done automatically and watch how the partitions are formatted and the software packages are copied to your hard drive. The installation process will take about 8-10 minutes (depending on your computer specs and the selected packages).

31


Lab Manual -1

10)

Restart your computer after successful installation

When the installation is over, you will get a "Congratulations, the installation is complete" screen. Click on “Reboot� button and your computer will automatically restart.

Note: Remove the DVD from your optical drive. Now Fedora 9 Linux operating system will start for the first time.

32


Install Your Operating System (WINDOWS/LINUX)

The system will boot...

And, before you reach the Fedora desktop, you must do a one-time general system configuration. Now log in to your new Linux operating system.

33


Lab Manual -1

1.3.3 Linux Utilities and Basic Commands The following are some of the basic commands used in the CLI Linux operating system, however GUI option is always available, as in the case of Windows: a) alias

Alias is used to substitute a small or more familiar name in place of a long string. It is commonly used for a long strings that are frequently used. Syntax alias [name=['command']] Name Specifies the alias name. Command Specifies the command the name should be an alias for. -a Removes all alias definitions from the current shell execution environment. -t Sets and lists tracked aliases. -x Sets or prints exported aliases. An exported alias is defined for scripts invoked by name. Example

$alias home 'cd public_html' - Sets home to type cd public_html. Use the command ‘unalias’ to remove this alias.

Alias command can be used even for the following: $alias clr clear $alias cls clear $alias copy cp –I $alias del rm –I $alias delete rm –I $alias home cd ~ $alias md mkdir $alias move mv –I $alias type more b) awk

awk utility is powerful data manipulation/scripting programming language (In fact based on the C programming Language). Use awk to handle complex task such as calculation, database handling, report creation etc. Syntax

awk -f {awk program file} filename awk Program contains are something as follows: Pattern{ action1 action2 actionN }

awk reads the input from given file (or from stdin also) one line at a time, then each line is compared with pattern. If pattern is match for each line then given action is taken. Pattern can be regular expressions. 34


Following is the summery of common awk metacharacters: Metacharacter

Meaning

. (Dot)

Match any character

*

Match zero or more character

^

Match beginning of line

$

Match end of line

\

Escape character following

[]

List

{}

c) cd

d) chmod

Install Your Operating System (WINDOWS/LINUX)

Match range of instance

+

Match one more preceding

?

Match zero or one preceding

|

Separate choices to match

The cd sets the working directory of a process. Syntax

cd <directory name>

Example

$cd /etc

Chmod is a utility that changes the permission of a file. Syntax

chmod [OPTION]... MODE[,MODE]... FILE...

Permissions u - User who owns the file. g - Group that owns the file. o - Other. a - All. r - Read the file. w - Write or edit the file. x - Execute or run the file as a program. Numeric Permissions: CHMOD can also to attributed by using Numeric Permissions: 400 read by owner 040 read by group 004 read by anybody 200 write by owner 020 write by group 002 write by anybody 100 execute by owner 010 execute by group 001 execute by anybody Example $chmod 644 file.htm This gives the file read/write by the owner and only read by everyone else (-rw-r--r--). $chmod 755 file.cgi $chmod 666 file.txt 35


Lab Manual -1

e) chown

Chown is a utility that is also used to change file ownership. Syntax

chown [R] owner[:group] file ...

-R recursively change file user and group IDs. For each file operand that names a directory, chown shall change the user ID (and group ID, if specified) of the directory and all files in the file hierarchy below it. Example f) cp

g) date

The cp command is used to copy files. Syntax

$cp source destination

Example

$cp abc.txt pqr.txt [copy the file abc.txt as pqr.txt] $cp *.txt /etc/ [ copy all files with .txt extension into /etc directory] $cp a* /etc/ [ copy all files starts with the letter ‘a’ into /etc directory]

An essential command to set the date and time. Also a useful way to output current information when working in a script file. Example

h) df

#chown root file.txt

$date

The df command reports filesystem disk space usage. With no arguments, `df' reports the space used and available on all currently mounted filesystems (of all types). Otherwise, `df' reports on the filesystem containing each argument file. Syntax

df [option]... [file]...

Normally the disk space is printed in units of 1024 bytes, but this can be overridden. OPTIONS

`-i'

List inode usage information instead of block usage. An inode (short for index node) is contains information about a file such as its owner, permissions, timestamps, and location on the disk.

`-k'

Print sizes in 1024byte blocks, overriding the default block size.

`-m'

Print sizes in megabyte (i.e.; 1,048,576-byte) blocks.

Example $df –k 36

$df –m

$df –i


i) pwd

j) ln

To know the current working directory Syntax pwd Example $pwd The ln command makes new, alternate file names for a file by hard linking, letting multiple users share one file. The ln command creates pseudonyms for files which allows them to be accessed by different names. These pseudonyms are called links. There are two different forms of the command and two different kinds of links that can be created. Syntax

Install Your Operating System (WINDOWS/LINUX)

ln [options] exiting_path [new_path] ln [options] exiting_paths directory

In the first form, a new name is created called new_path which is a psuedonym for existing_path. In the second form, the last argument is taken to be a directory name and all the other arguments are paths to existing files. A link for each existing file is created in the specified directory with the same filename as the existing files. Example Create a link named my_file in the current directory to the file /home/bill/his_file: $ln /home/bill/his_file my_file As above but the link is created in /home/joe/my_file: $ln /home/bill/his_file /home/joe/my_file To create a symbolic link, all works as above except you need to include the -s option. For example, to make a symbolic link called linux that points to fedora: $ln -s linux fedora The only way to see that linux is a symbolic link is by using the ls -l command (ls -l linux). The output of this command will look much like this: lrwxrwxrwx 1 joe users 3 2009-03-21 17:26 linux -> fedora k) ls

The ls command shows information about files. It lists the contents of a directory in order to determine when the configurations files were last edited. Syntax ls [-a] [-A] [-c] [-d] [-i] [-l] [-L] [n] [-r] [-R] [pathnames] 37


Lab Manual -1

-a: shows all files, even files that are hidden (these files begin with a dot.) -A: list all files including the hidden files. However, does not display the working directory (.) or the parent directory (..). -c: use time of last modification of the i-node (file created, mode changed, and so forth) for sorting (-t) or printing (-l or -n). -d: if an argument is a directory it only lists its name not its contents. -i: for each file, print the i-node number in the first column of the report. -l: shows you huge amounts of information (permissions, owners, size, and when last modified.) -L: if an argument is a symbolic link, list the file or directory the link references rather than the link itself. -n: The same as -l, except that the owner's UID and group's GID numbers are printed, rather than the associated character strings. -r: reverses the order of how the files are displayed. -R: includes the contents of subdirectories. Example l) man

$ls –d

$ls -r

Short for "manual," man displays information about commands and a keyword search mechanism for needed commands. Syntax Example

m) passwd

$ls –l

man <command> $man find

$man chown

A quick and easy way to change passwords on a system. Syntax passwd [-d account name] Example #passwd #passwd –d xyz

[ to delete the password of the account ‘xyz’]

n) Shutdown Shutdown is a command that turns off the computer and can be combined with variables such as -h for halt or -r for reboot. Syntax Shutdown [-h][-r] Example o) top

38

#shutdown

Top provides an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive interface for manipulating processes. Syntax

top

Example

$top


p) vmstat

The vmstat command is used to get a snapshot of everything in a system, helping admins determine whether the bottleneck is CPU, memory or I/O. Run this command to get virtual memory statistics. vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity. Syntax

vmstat [-a] [-n] [delay [ count]] vmstat [-f] [-s] [-m] vmstat [-S unit] vmstat [-d] vmstat [-p disk partition] vmstat [-V]

Example

$vmstat

Install Your Operating System (WINDOWS/LINUX)

Lab Exercises 2 1)

What are various features of windows operating system? Check them. …………………………………………………………………………………… …………………………………………………………………………………… …………………………………………………………………………………….

2)

Write and run some basic commands of Linux operating system. …………………………………………………………………………………… …………………………………………………………………………………… …………………………………………………………………………………….

3)

Find various releases/versions of Windows operating system. …………………………………………………………………………………… …………………………………………………………………………………… …………………………………………………………………………………….

4) 5) 6)

Practice to install Windows XP in your computer. Practice to install Fedora 9 in your system. While Loading Fedora 9 on your system, what amount of memory space should be allocated to Swap space and why? …………………………………………………………………………………… …………………………………………………………………………………… …………………………………………………………………………………….

1.4 SUMMARY The installation process of two well known O.S. i.e., Windows XP and Fedora, contributing to Proprietary and Open source community are discussed. Apart from the peculiar technicalities and tasks one has to perform while installing the O.S. are also discussed. In the Fedora part the exploration of some useful CLI commands is also performed, however to work with Fedora professionally you need to refer to the

39


Lab Manual -1

Further readings section given at the end of this unit & may need to explore the internet for further help. Apart from this Different versions/releases of both Windows and Linux are clearly specified from first release to till latest release of each. Various features of both the operating systems are also explained. At last the purpose of this unit is to let you perform the actual installation procedures of Windows (Windows XP) and Linux (Fedora 9).

1.5 SOLUTIONS/ANSWERS Lab Exercises 1

40

1)

No, because the minimum requirement of RAM is 64MB.

2)

No, the performance is not affected, if the size of the hard disk is not that high. But if processor is slow i.e. of less frequency and other parameters and RAM is Less then by attaching very high capacity hard disk (directly i.e. not in master slave manner) will make the system slow.

3)

No, the performance will be severely affected. For arguments, refer to answer given above.

4)

For development of some commercial application the NT or Server technologies are generally preferred to work with , because these type of O.S. are specifically designed to support the network/Client server and other environments.

5)

Yes, Symbian is one of the well known O.S. apart from this Windows Mobile edition is also there and many other are in pipeline , but these two are quite famous.

6)

Yes, even if the GUI of an Windows O.S. is loaded, then also we can work with its CLI. You can switch yourself from one mode to other i.e. GUI to Non GUI (i.e.CLI), depending on your choice. Below the installation process of Windows XP is given, once it is loaded, then you can click your mouse on Start menu, go to Run, click in it a window will pop up, in the box simply write cmd and press enter, you will see the DOS prompt as shown below which is the CLI of the GUI i.e. Windows XP loaded by you.

7)

The O.S. itself resides in the Hard Disk of the system and that’s why the minimum system requirement takes care of hard disk specifications too.

8)

Whenever you are working with your computer system, do not save your data in to the disk space or drive where your O.S. resides, because if something goes wrong and you need to format your system then your data will also be lost. Generally O.S. is loaded in C: drive, so avoid saving your data in this drive and save it in other partitions. So that your data is safe, even if some thing goes wrong and you need to format your system.


Lab Exercises 2 1)

Install Your Operating System (WINDOWS/LINUX)

The following are various features of Windows operating system : User Interface & Device support Accessibility and Usability Remote desktop Power management

2)

The following are some basic commands of the Linux operating system alias, ls, ln, find, awk, passwd, shutdown, vstat, top, cp and cd

3)

The following are various releases/versions of Windows operating system The first version of Microsoft Windows i.e version 1.0, released in the year 1985. Later different versions of windows( windows 2.0, 3.0, 3.1, windows 95, windows 98 and windows XP) over a period till 2001 and then in the year 2007, Microsoft released windows Vista. Microsoft released in parallel the network operating system for servers for various network services also.Windows NT 3.1 is the first release of Microsoft's Windows NT line of server in the year 1993. Since then, Microsoft released various versions (Windows NT 4.0, Windows 2000, Windows server 2003 and Windows server 2008) over a period till 2008.

4)

Exercise yourself

5)

Exercise yourself

6)

For proper installation keep the size of swap space or swap area, approximately greater than or equal to the double of the size of the RAM of your system, the reason behind requires more in depth understanding of the concepts of O.S. , which can’t be discussed at this level. However the concern is related to the paging and segmentation management when swaps in the memory segments are performed.

1.6 REFERENCES/FURTHER READINGS •

http://www.microsoft.com/windowsxp/using/setup/winxp/install.mspx

http://www.linux.org

http://www.fedoraproject.org

http://www.redhat.com/docs/manuals/linux

41


Lab Manual - 1

UNIT 2 WRITING A PROGRAMME IN ‘C’ Structure

Page Nos.

2.0

Introduction

42

2.1

Objectives

43

2.2

Structure of C Program

44

2.3

Execution of C Program

44

2.4

Basic Data Types and Operators

47

2.4.1 Examples Programs

56

Control Structures

58

2.5.1

If Statement

58

2.5.2

While Loop

60

2.5.3

Do-While Loop

61

2.5.4

For Loop

61

2.5.5

Break and Continue

63

2.5.6

Switch Statement

65

Complex Data Types

67

2.6.1

Structures

67

2.6.2

Arrays

68

2.6.3

Strings

71

2.6.4

Pointers

73

2.6.5

User Defined Type Declaration

74

2.5

2.6

2.7

2.9

Functions

77

2.7.1

Declaration and Definition of Functions

78

2.7.2

Characteristics of Function

79

2.7.3

Call by Value and Call by Reference

80

Summary

2.10 References/Further Readings

84 84

2.0 INTRODUCTION

42

This Unit will introduce you to the practical aspects of C Programming which includes defining the basic structure of C program and how to execute a C Program. However, to make this Unit more useful, we have added some basic concepts of C Programming in this Unit, which provides a basic recapitulation of the concepts that you have already learnt and some more concepts that are added here for the purpose of future reference. As far as C is concerned, it is a language for professional programmer’s and is a structured language by nature. C was designed and developed by Kernighan and Ritchie who wrote the original language definition in their book, “The C Programming Language”, i n 1 9 7 8 as their research.


The C Programming Language was developed by Bell Laboratories in the early

Writing a Programme in ‘C’

seventies. It had two predecessor languages BCPL and B. C is a High Level Language that was designed with the main objective of writing portable system programs. (A portable program is the one that can be ported from one hardware platform to other. One of the most common system program is the Operating System). The C was used to write the UNIX operating system so that it can be ported to different hardware with minimum of rework. The formal ANSI standard for C was produced in 1989. ANSI C supports the procedural programming paradigm. In 1986 a descendent of C was developed by Bjarne Stroustrup that supported the Object Oriented programming paradigm. In order to successfully complete this unit, you will not need any prior knowledge of the C programming language. We will begin with the most basic concepts of C and take you up gradually. Programming in C is a tremendous asset in those areas where you may want to use Assembly Language but would rather keep it a "simple to write" and "easy to maintain" program. Throughout this Unit, every attempt will be made to indicate to you what constructs are available in every C compiler because they are part of the ANSI-C standard, the accepted standard of C. The examples given in this Unit are ANSI C compliant and can be run on any compiler, as most of the compilers are ANSI C compliant. However, please note that this Unit cannot cover all aspects of programming in C, simply because there is too much to cover, but it will instruct you in all you need for the majority of your programming in C, and it will introduce essentially all of the C language.

2.1 OBJECTIVES After studying this unit, you should be able to:

identify the structure of the C program;

compile, execute and debug the C program;

identify and use the various data types and operators in your programs;

use appropriate control structures, to fit in to the logic of your program;

use basic data types to buid the complex data types; and

implement your logic with the help of functions.

43


Lab Manual - 1

2.2 STRUCTURE OF C PROGRAM A C program may contain one or more sections as shown below : Documentation Link Section Definition Section Global declaration Section Main () function section { Declaration part Execution part } Subprograms user defined functions Function1 Function 2 | Function N The Document section consists of a set of comment lines giving the name of the program, the author and other details which programmer would like to use later. The Link section provides instructions to the compiler to link functions from the system library. The Definition section defines all symbolic constants. There are some variables that are used in more than on e function. Such variables are Global variables and are declared in the Global declaration section that is outside of all the functions. Every C program must have one main() function section, this is the section, from where the execution of the program starts. This section contains two parts i.e. declaration and executable. The declaration part declare all the variables used in the executable part. These two parts must appear between the opening and closing curly braces i.e.{--}. Program execution starts at the opening braces and terminates at the closing braces. All statements in declaration and executable part must terminate with semicolon (;). The Subprogram section contains all the user defined functions which are called in the main() function. In the subsequent section we will study the details of the sections described here.

2.3 EXECUTION OF C PROGRAM In the previous section, you have seen the structure of a C program. But what steps do you need to follow to execute a C program. Executing a program written in C programming language involves a series of steps. These are: 44


1. 2. 3. 4.

Creating the program Compiling the program Linking the program with the functions that are needed from the library Executing the program

Writing a Programme in ‘C’

You need to install a C compiler to compile and execute a C program. You should make sure that your compiler is ANSI C compliant, and also has the ability to generate an executable file. The steps of execution of the program, which are listed above are independent of the operating system. However, please note that the commands that may be required to be executed by you may be different. Further, it should be noted that the conventions for naming files may differ on different systems. All of the example programs in this unit will compile and execute correctly with any good ANSI compliant C compiler. Fortunately, most of the C compilers available have a means of compiling a standard C program which is written for the DOS environment and includes none of the Windows extensions. You should check the documentation about the compiler that you are using for the capabilities and limitations. Most of these compliers include integrated development platform for large projects in C and C++. However, you may initially use them for developing simple C programs. Some of the popular compilers are : Turbo C is an Integrated Development Environment (IDE) for C Programming Language from Borland. It is low priced software. It is a small compiler and has fast compilation speed. Borland C++ is a C and C++ programming environment by Borland that was meant to replace Turbo. However, Turbo is still used at many places. Borland has better debugger than Turbo. Microsoft Visual C++ (you may find it as a part of Microsoft Visual Studio package) is a commercial IDE for C, C++ with advanced library support for developing applications in Windows environment. Dev C++ is also an IDE for the C and C++ programming languages. This software is available for FREE under the GNU General Public License (GPL). GCC was GNU C Compiler. However, now this compiler supports many other languages including C++, Fortran, Java etc. It now is called the GNU Compiler Collection. The rest of this section will be devoted to give you a brief overview about how to use two of these compilers – Turbo C and Dev C++. 45


Lab Manual - 1

Using Dev C++: Dev C++ compiler can be downloaded from the website http://www.bloodshed.net You need to perform the following steps to use Dev C:

• • • •

You can install the compiler by executing its installation file most likely named setup.exe. You will find that a folder Dev-cpp is created in the folder you have installed Dev C++. Opening this folder you will find that it contains again many folders/contents. Out of these folders BIN is very important, however, you may like to explore the contents of other folders like LIB, DOC, INCLUDE etc., to enhance your knowledge about the subject. Now, to write a program like the sample program, you need to run the Dev C++ software. You can run the Dev C++ compiler from Start Menu of Windows by selecting: “Start” “Programs” “Bloodshed Dev-C++” “DevC++”. A GUI window will be at your disposal to write and run your programs. Now, you open the file menu, choose the new option, a n d s e l e c t t h e o p t i o n “ S o u r c e F i l e ” . A blank window will appear with flashing cursor, key in the program in it and finally save the file by selecting “File” “Save As” option. This will open a dialog box where you can select a file name. Please make sure that in the dialog box, “SAVE AS TYPE” you select the option “C source files (*.c)” as you are creating a C program source file. Once you have keyed in the program correctly, you can compile it using the Menu option “Execute” “Compile” and if there are no compilation errors, then you can run the program you have created by selection the Menu Option “Execute” “Run”. Alternatively, you can also use the shortcut keys to compile and run the program. You can Press CTRL+F9 to compile the program and CTRL-F10 to run the program if it has been successfully compiled. If your programmas, has, no compilation error then it will run fine and to see your output you can simply press CTRL+F5; other wise the errors will be listed. In this case, you need to identify the errors and debug your code till all the errors are removed. At this point your code will be ready to run. Finally to quit either use “File” “Exit” option of the File menu.

Using Turbo C: Turbo C compiler is easy to use compiler for beginners. If you want to use Turbo C, you must make sure that you get licensed copy of the Software. you need to perform the following steps to use Turbo C:

• • 46

You can install the compiler by executing its installation file i.e. TC.exe. You will find that a folder TC is created in the folder you have installed Turbo C. Opening this folder you will find that it contains again many folders/contents.


• •

• •

Out of these folders BIN is very important, however, you may like to explore the contents of other folders like; LIB, DOC, INCLUDE etc., to enhance your knowledge about the subject.

Writing a Programme in ‘C’

Now, to write a program like the sample program, you need to open the BIN folder and find the file named TC.exe inside it. You should double click on this file and a GUI window will be at your disposal to write and run your programs. Now you open the file menu, choose the new option, a blank window will appear, key in the program in it and finally save the file (by pressing function key F2 or use the save option of file menu) with the extension c. For example, you can give name as citprogram1.c, try.c, program1.c etc. Pl ea s e n o te th at the file will automatically be saved in the BIN folder. You may explore the BIN folder to locate your saved file. Although when you look at the menu bar, you will find that the options for compiling and running the programs are available there, but you can simply use ALT+F9 or Ctrl+F9 to perform the job. The program will first be compiled. If your program no compilation error then it will run fine and to see your output you can simply press ALT+F5; other wise the errors will be listed. In this case, you need to identify the errors and debug your code till all the errors are removed. At this point your code will be ready to run. Finally to quit either use QUIT option of the File menu or use ALT+X.

An important observation about Dev C++ and Turbo C for you. The moment you save a file, let us say with the name u2prog1.c, only one file of name try exists in the BIN folder, having the extension .c. But after compiling you find that three more files with same name but with different extensions (i.e .obj, .bak, .exe) appear in the BIN. The answer is hidden in the steps of execution of C program. You wrote u2prog1.c after compiling u2prog1.obj file is created further to take care of errors in your created file, the u2prog1.bak file is generated and finally on linking the u2prog1.obj file with the system libraries u2prog1.exe is created. So, you create u2prog1.c and system will create u2prog1.obj, u2prog1.bak and u2prog1.exe along with u2prog1.c and all these files will reside in BIN folder. The following sections present a brief Recapitulation of C Programming. Please note that it is not complete C programming. You may refer to further readings, if you want to know more about C.

2.4 BASIC DATA TYPES AND OPERATORS The concept that you must learn first before any programming language is ─ what is an identifier and, how to name an identifier. An identifier is the distinguishing name that is used for a variable or function or data definition in a C program. 47


Lab Manual - 1

An identifier in C programming language can consist of a combination of alphanumeric characters, the first being a letter of the alphabet or an underline, and the remaining being any letter of the alphabet, any numeric digit, or the underline. While using the identifiers one has to keep in mind that that, C compiler is case sensitive, i.e., it takes capital letters and small letters or even their combination, differently C provides a standard, minimal set of basic data types. Sometimes these are called "primitive" types. More complex data structures can be built up from these basic types. These data types specifies that identifiers may be of the following types or may be designed to return the data of following types as given below in Table 1. Table 1 : Data Types Type Name

Bytes

Range 16 bit system

1

-128 to 127

signed char

1

-128 to 127

unsigned char

1

0 to 255

short

2

-32,768 to 32,767

unsigned short

2

0 to 65,535

2

-32,768 to 32,767

unsigned int

2

0 to 65,535

long

4

-2,147,483,648 to 2,147,483,647

unsigned long

4

0 to 4,294,967,295

float

4

3.4E+/-38 (7 digits)

double

8

1.7E+/-308 (15 digits)

10

1.2E+/-4932 (19 digits)

char

int

long double Type Name

Bytes

Range 32 bit system

1

-128 to 127

signed char

1

-128 to 127

unsigned char

1

0 to 255

short

2

-32,768 to 32,767

unsigned short

2

0 to 65,535

char

4

-2,147,483,648 to 2,147,483,647

unsigned int

4

0 to 4,294,967,295

long

4

-2,147,483,648 to 2,147,483,647

unsigned long

4

0 to 4,294,967,295

int

float

4

3.4E+/-38 (7 digits)

double

8

1.7E+/-308 (15 digits)

10

1.2E+/-4932 (19 digits)

long double 48


char

It is ASCII character of at least 8 bits. As a practical matter char is basically always a byte which is 8 bits which is enough to store a single ASCII character. 8 bits provides a signed range of –128 to 127 or an unsigned range is 0 to 255. char is also required to be the "smallest addressable unit" for the machine -- each byte in memory has its own address.

int

It is default integer o f at least 16 bits, with 32 bits being typical. Defined to be the "most comfortable" size for the computer. If you do not really care about the range for an integer variable, declare it intsince that is likely to be an appropriate size (16 or 32 bit) which works well for that machine.

float

A single precision floating point number i.e. numbers with a decimal point and a fractional part with a limited accuracy. It typically occupies 4 bytes.

double

A double precision floating point number i.e., float type but with better precision of accuracy. It occupies 8 bytes.

NOTE

Further the data holding capacities of these fundamental data types can be modified by starting or prefixing the name of these data types with any of the following types of modifiers i.e., short, long, unsigned short, signed, unsigned, unsigned long etc. as enlisted above, it is to be noted that their incorporation along with the fundamental data type modifies the data managing capacity of the identifier, for example

Writing a Programme in ‘C’

Apart from the knowledge of the data types and their respective data holding capacities we need to know what are the various keywords available, to write a C program.

There are 32 words defined as keywords in C. These have predefined uses and cannot be used for any other purpose in a C program. They are used by the compiler as an aid to compiling the program. They are always written in lower case. A complete list is given in the table 2. Table 2: Key Words auto

double

int

struct

break

Else

long

switch

case

Enum

register

typedef

char

extern

return

union

const

Float

short

unsigned

continue

For

signed

void

default

Goto

sizeof

volatile

do

If

static

while 49


Lab Manual - 1

In addition to this list of keywords, your compiler may define a few more. If it does, they will be listed in the documentation that came with your compiler. Almost each of the above keywords will be defined, illustrated, and used in this unit. Further to write a program, we need to have the knowledge of data and structuring of program, none the less the comments also plays vital role in enhancing the readability of the program. Comments in C are enclosed by slash/star pairs : /* .. comments .. */ which may cross multiple lines. C++ introduced a form of comment started by two slashes and extending to the end of the line: // comment until the line end The // comment form is so handy that many C compilers now also support it, although it is not technically part of the C language. Any computer program has two entities to consider, the data, and the program. They are highly dependent on one another and careful planning of both will lead to a well planned and well written program. Unfortunately, it is not possible to study either completely without a good working knowledge of the other, so, knowing the syntax rules for writing program is must., because before writing a program we should know what is the program syntax and what are the basic rules to write a program. Syntax Rules and Key Notes for beginners in C 1)

‘C’ is a free format language i.e., we can start writing anywhere on a line unlike other languages like; COBOL, FORTRAN etc.

2)

Any line that has # (called hash) character appearing in the first column, is a line that is extracted and processed by C preprocessor. These lines contain directives that cause the ‘C’ preprocessor to include ‘C’ source code from other files.

3) Preprocessors the C compiler has a preprocessor which reads the source code and does some processing before passing it to the compiler for the purpose of compilation. The preprocessor commands are not normal C command and they are signaled to the compiler by putting # in the first column followed by the preprocessor command, table of preprocessor options is given below:

50

# define

Define a constant or a macro.

# include

Inserts a text i.e., a portion of the program from the other text file.

# undef

Remove a macro or constant definition.

# ifdef

Ignore or include the following lines of code in the program. depending upon whether a name has a macro definition or not

# ifndef

Similar to ifdef but with reverse test.

# if

Include or ignore the following lines of code depending upon the value of the expression to be 0 or 1.

# endif

Termination of a #if, #ifdef or #ifndef.

# else

Corresponding to #if, #ifdef and #ifndef for the else part.


4) A ‘C’ program, in general consists of many functions in addition to a function called main, which may be standard or developed by the programmer. This function main must be mentioned only once in the program and since program execution starts from main only , so it must be the first function, and can be followed by any number of functions. The format of main function is main(). Note: • The blank parenthesis following the main indicates that there are no arguments to the main program. However, the arguments can be given, they are argc (argument count) and argv (argument variable), generally used for command line programming. The main function is present in the TLIB folder of the turboC compiler. • C uses curly braces ({}) to group multiple statements together. The statements execute in order. Some languages let you declare variables on any line (C++). Other languages insist that variables are declared only at the beginning of functions (Pascal). C takes the middle road -- variables may be declared within the body of a function, but they must follow a '{'. More modern languages like Java and C++ allow you to declare variables on any line, which is handy.

Writing a Programme in ‘C’

5) Variables: User defined variable names must follow following rules : a) First character must be a letter, remaining characters can be letters or digits or underscore b) Lowercase and upper case letters are different. c) Although there is no restriction on the variable names, but only first 8 characters are taken, so the first 8 characters of two variables should be different. d) Variable should not be a reserved word i.e. keyword. e) Each variable must be declared before its usage within the program, this declaration is achieved by linking variable name to its type. f) Variable may be an array or pointer of respective data type- we will discuss them later. g) Storage classes and their meaning. Storage class

Meaning

auto

Local variables declared inside the function. Default is auto. No need to specify/write storage class.

static

It may be internal or external type. Local variable which exists and retains its value even after the control is transferred to the calling function.

extern

Global variables are known and available to all the functions in the file.

register

Local variable which is stored in the register of CPU instead of memory.

h) On the basis of the scope of a variable (i.e., the region in which the variable can perform), the variables are classified as:

51


i)

Lab Manual - 1

ii)

External Variables : Variables whose scope is entire program, declared before main() or the function definition, the external variables are available in main() as well as in the other functions defined in the program, and share the same memory location, thus their value is available in all the functions including main( ). Internal or Local or Automatic Variables : Variables whose scope is limited to the region where they are specified, declared inside the functions. A local variable exists only as long as the function where it is declared is still executing (we'll see functions shortly).

NOTE:

• • •

52

Two variables defined with in two functions with the same name are different, they do not share the common memory location. External variables are defined so that that they remain common to more than one function with in the same source file, these external variables are also called as Global variables. However, C provides for storing the functions in different source files and to compile these separately. In such case, we might like the global variable to be defined across a single source file. For this purpose, we use extern statement. The external variables need to be defined in one source file only. In the other source files, these variables should be defined with the extern statement. The variables declared in the extern statement share the common memory location in the other source files with the same name. No, new location is reserved for those variables syntax: extern type variables; Local variables are internal to the function in which those are defined. After the execution of the function these values are undefined for optimization of the code the C compiler can assign the same memory location to other internal variables of another function. Thus, without the knowledge of the programmer, the memory addresses can be assigned and reassigned to different variables by the compiler. However, it does not happen in the case of external variables, because their definition is valid across the functions, and the addresses assigned are permanent which cannot be reassigned to any other variable by the compiler. By extern, these extern variables can be shared across the source files Static Variable : If we want that the a permanent address should be assigned to the internal variable then that variable should be declared as static. Declaring an internal variable as static, the addresses of the variables remain fixed during the multiple calls to the same function. The static variables have their scope limited to one source file, these can not be extended to other source files as in the case of the external variable with the use of extern. So, static variables can not appear in the extern statement. Register Variables : It is another storage class offered by C, the use of these register locations has limitations depending upon the type of hardware being used. The registers are special memory locations with in the hardware which


6)

7)

are faster than the normal memory locations. The memory locations which are often used by the program can be declared as register type, so that the compiler stores them in these memory locations for faster processing, syntax : register type variables; Constants : C provides various types of constants : a) Integer constants i) Decimal notations e.g. 457, -457,593L,etc. ii) Octal notations e.g. 056 i.e. 46 is decimal value of octal 056 iii) Hexadecimal notations e.g. 0x 9A4F b) Float constants iv) Standard notations e.g. 23.5, -95.375,46370.0 v) Scientific notations e.g.4.3E4 (m E n, m-mantissa, n-exponent) c) Character constants e.g. ‘a’,’$’,’9’ vi) Special character constants or backslash character constants ‘\a’ Audible alert (bell) ‘\b’ back space ‘\f’ form feed ‘\n’ new line ‘\r’ carriage return ‘\t’ horizontal tab ‘\v’ vertical tab ‘\’’ single quote ‘\’’’ double quote ‘\?’ question mark ‘\\’ back slash ‘\0’ null d) String constants, is assumed to be array of type char, later we will learn what arrays are, e.g.”C is Great”.

Writing a Programme in ‘C’

Whatever may be the type of variable or constant but to have output or to give input you need to work with some standard functions like printf and scanf, and to work with them you need to have idea of the format codes, which support the concerned data types, a list of format codes is given below in table 3. Table 3 : Format Codes Code

Meaning

%d

for decimal output of an integer

%o

for unsigned octal output(without the leading zero)

%x

Hexadecimal output(without the leading OX)

%u

unsigned decimal output of an integer

%c

character output of a character variable

%s

output of a string

%e

output of a float or double value in exponent notation e.g. 4.1 E 3

%f

output of a float or double value in fixed notation e.g. 4.543

%g

output of a float or double value in %e or %f which ever is shorter.

%%

output a single % symbol 53


Note: in between the % and the format conversion characters listed above , there may be :

Lab Manual - 1

• •

A minus sign to indicate left alignment within the field, by default all values are just right justified An number specifying the field width, precision etc.

8)

The letter l, indicating the data item is a long int Operators are essential to form expressions to perform arithmetical and logical operations, the operators are classified as : a) Assignment operator (=) b) Arithmetic operators (unary minus; *, / , % ; +,-,) c) Relational operators (= =, !=, >, >=, <, <=) d) Logical operators (&&, ||, ! ) e) Increment & decrement operators (var++, var--, ++var, --var) f) Bitwise operators(&, |, ^, <<, >>) g) Ternary operator (exp1 ? exp2 : exp3) List of all C operators are given in Table 4 : Operator Precedence Table. This table shows the order of precedence in the evaluation, operators of group1 are evaluated first followed by that of group 2 and so on. The order should be kept in mind while evaluating any expression. Table 4 : Operator Precedence Table GROUP

OPERATOR

MEANING

1

()

Parenthesis and function invocation

[]

Array subscripting Pointer qualification Structure qualification

2

3

4 54

!

Logical negation

~

Bitwise ones complement

++

Increment

--

Decrement

-

Unary minus

Type

Type

*

Pointer dereferencing

&

Address of operand

Sizeof

Size of

*

Multiplication

/

Division

%

Remainder

+

Addition

-

Subtraction


5

<<

Shift left bits

>>

Shift right bits

<

Less than

<=

Less than or equal to

>

Greater than

>=

Greater than or equal to

==

equal to

!=

Not equal to

8

&

Bitwise and

9

^

Bitwise exclusive or

10

|

Bitwise or

11

&&

Logical and

12

||

Logical or

13

?:

Ternary

14

=(+ = - = etc.)

Assignment

6

7

Writing a Programme in ‘C’

Note : C does not have a distinct Boolean type, in fact int is used instead. The language treats integer 0 as false and all non-zero values as true. So the statement i = 0; while (i - 10) { ...} will execute until the variable itakes on the value 10 at which time the expression (i 10)will become false (i.e. 0). (we'll see the while() statement a bit later) Standard Library Functions : Many basic housekeeping functions are available to a C program in form of standard library functions. To call these, a program must #include the appropriate .h file. Most compilers link in the standard library code by default. The functions listed in the next section are the most commonly used ones, but there are many more which are not listed here.

8)

stdio.h

file input and output functions like printf(), scanf() etc.

ctype.h

character tests

string.h

string operations like strcmp(), strcat() etc

math.h

mathematical functions such as sin() , cos() etc

stdlib.h

utility functions such as malloc() and rand() etc.

assert.h

the assert() debugging macros

time.h

date and time

Note: You can refer to the functions written inside these header files, by referring to the help section of the compiler you are using, for turbo C you simply press Ctrl+F1 and the help is activated for your reference, however a brief summary of the functions present in these header files is given at the end of this unit.

55


Lab Manual - 1

2.4.1

Examples Programs

If you are gone through the concepts discussed above then you are in the situation to write and understand the C programs, now you are advised to go through the programs given below, execute them and identify how they are working Program 1 : Write a Program to print “Hello, all of you” // Comments- this program will say hello to all of you #include <stdio.h>

// preprocessor include is used to include printf and scanf in //your program from header file stdio.h // start of the program

main() { printf(“Hello, all of you”);

// printf is the library function defined in // stdio.h and is used to print

} Program 2 : Write a Program to print sum and average of two numbers // program to fin sum and average of two numbers #include<stdio.h> main() { int a,b,sum, avg; // declaration of variables a=10; b=20; // assigning values to the variables sum=a+b; avg= sum/2; // performing addition and subtraction operation printf(“SUM = %d ; Average=%f”, sum, avg); // using format codes to print results } Program 3 :Write a program to print sum and average of two numbers entered by the user // program to fin sum and average of two numbers entered by the user #include<stdio.h> main() { int a,b,sum, avg; // declaration of variables scanf(“%d %d \n”, &a, &b); // using scanf function defined in stdio.h to take input printf(“you entered a= %d and b= %d \n”, a,b); sum=a+b; avg= sum/2; // performing addition and subtraction operation printf(“SUM = %d ; Average=%f ”, sum, avg); // using format codes to print results }

56


Note: In the above program3 see how printf and scanf statements are written, in scanf we are using &a and &b, because the values entered by the user are to be stored at the address of the variables a and b, so & is used. Where as in print statement only a and b are used, because when a and b are referred then result will come from the address location of variable a and b. Further \n is used to incorporate new line in the output.

Writing a Programme in ‘C’

Lab Exercises 1 1)

You are advised to write the program3 without \n and try printing the values of the address of a and b. ………………..………..………………………………………………………… …………………………………………………………………………………… …………………………………………………………………………………… ………………..………..…………………………………………………………

2)

Modify the program 2 to perform all basic mathematical operations like sum, difference, product, average, division ; on the two numbers entered by the user. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

3)

Run the program given below and analyze its output. #include<stdio.h> main() { int a = 98; //note here we are declaring and initializing the variable simultaneously float b = 23.566; char c = ‘A’; printf(“address of a : %d”, &a); printf(“Decimal : %d \n”, a); printf(“Octal

: %o \n”, a);

printf(“Hexa

: %x \n”, a);

printf(“Real

: %f \n”, a);

printf(“Real

: %e \n”, a);

printf(“Real

: %5.2 \n”, a);

printf(“Character : %c \n”, c); printf(“ASCII code of c : %d \n”, c); } 57


Lab Manual - 1

2.5 CONTROL STRUCTURES After going through the previous section we hope you got an idea about the basic components of C and their concerned syntax rules. Further to write a proper, well structured C program, we need to understand the working of various control structures, available to facilitate the writing of a C program. Control structures in C are classified as follows: 1. if, if-else 2. while, do-while 3. for 4. switch

2.5.1

If Statement

Both an if and an if-else are available in C. The <expression> can be any valid expression. The parentheses around the expression are required, even if it is just a single variable. Syntax of this control structure is as follows: Syntax 1 if (<expression>) <statement> clause

// simple form with no {}'s or else

Program 4 : Program for syntax 1 main() { int a=10,b=5,c=10; if(a>b) c=c+5; printf(“c=%d”,c); } Syntax 2 if (<expression>) { <statement> <statement> }

58

Program 5 : Program for syntax 2 main() { int a=10,b=5,c; printf(“a=%d b=%d”,a,b); if(a!=b) { c=a; a=b; b=c;

// simple form with {}'s to group statements


printf(“values of a and b are interchanged”); } printf(“Interchanged values a=%d b=%d”,a,b); } Syntax 3 if (<expression>) { <statement> } else { <statement> }

Writing a Programme in ‘C’

// full then/else form

Program 6 : Program for syntax 3 main() { int a=10,b=5,c; printf(“a=%d b=%d”,a,b); if(a!=b) { c=a; a=b; b=c; printf(“values of a and b are interchanged”); } else { printf(“a and b are equal”); } } Conditional Expression -or- The Ternary Operator : The conditional expression can be used as a shorthand for some if-else statements. The general syntax of the conditional operator is: <expression1> ? <expression2> : <expression3> This is an expression, not a statement, so it represents a value. The operator works by evaluating expression1. If it is true (non-zero), it evaluates and returns expression2 . Otherwise, it evaluates and returns expression3. The classic example of the ternary operator is to return the smaller of two variables. Every once in a while, the following form is just what you needed. Instead of... if (x < y) {min = x;} else {min = y;} You just say min = (x < y) ? x : y;

59


Lab Manual - 1

Program 7 : Program to find maximum of three numbers entered by the user // program to demonstrate the use of nested if statement #include <stdio.h> main() { int a,b,c,high; printf(”enter three numbers”); scanf(“%d %d %d \n\n”,&a,&b,&c); if(a>b) if(a>c) high = a; else high = c; else if(b>c) high = b; else high = c printf(“Highest = %d \n”, high); } Now you are advised to write the program7 by using Conditional Expression i.e., The Ternary Operator( : ? )

2.5.2

While Loop

The while loop evaluates the test expression before every loop, so it can execute zero times if the condition is initially false. It requires the parenthesis like the if., the syntax is as follows while (<expression>) { <statement> } Program 8 : Program to dump the contents of input using while /* this program reads the data until ‘$’ is entered by the user and prints it, here we use the getchar() and putchar() functions defined in stdio.h*/ #include<stdio.h> main() { char c; while((c=getchar())!=’$’) putchar(c ); //here I/O of the data is performed without using scanf and printf i.e. no %c, & etc } 60


2.5.3

Do-While Loop

Writing a Programme in ‘C’

Like a while, but with the test condition at the bottom of the loop. The loop body will always execute at least once. The do-while is an unpopular area of the language, most everyone tries to use the straight whileif at all possible. do { <statement> } while (<expression>) Program 9: Program to print 10 numbers using do-while #include<stdio.h> main() { int a=1; do{ printf(“%d \n”,a); a++; //a++ means a=a+1 } while(a<11) }

2.5.4

For Loop

The for loop in C is the most general looping construct. The loop header contains three parts: an initialization, a continuation condition, and an action. for (<initialization>; <continuation>; <action>) { <statement> } The initialization is executed once before the body of the loop is entered. The loop continues to run as long as the continuation condition remains true (like a while). After every execution of the loop, the action is executed. The following example executes 10 times by counting 0..9. Many loops look very much like the following. for (i = 0; i < 10; i++) { <statement> } C programs often have series of the form 0..(some_number-1). It's idiomatic in C for the above type loop to start at 0 and use < in the test so the series runs up to but not equal to the upper bound. In other languages, you might start at 1 and use <= in the test. Each of the three parts of the forloop can be made up of multiple expressions separated by commas. Expressions separated by commas are executed in order, left to right, and represent the value of the last expression. (See the string-reverse example below for a demonstration of a complex for loop.) 61


Lab Manual - 1

NOTE • Writing of initialization and action expression is optional, if they are omitted then they are simply bypassed. But semicolon must be there to segregate the initialization and action phase from the continuation one i.e., statement like for( ; c>10 ; ) //is acceptable further if none of the expression is given then the loop runs infinitely i.e., for( ; ; ) //runs infinitely Program 10: Program to print the table (i.e., first 10 multiples) of the number entered by the user using for, and in a tabular form #include<stdio.h> main() { int a, b, c; printf(“Enter the number, whose table is desired :”); scanf(“%d”, &a); for(b=1;b<=10;b++) { c=a*b; printf(“%d X %d = %d ”, a,b,c); } } • Break and Continue plays vital role in altering the looping sequence, their functioning is discussed below : Lab Exercises 2 1)

Write a program to print the entire list of the ASCII codes. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

2)

Write a program to print a right angled triangle using “*”. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

3)

Write a program to identify that the entered number id prime or not. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

4)

Write a program to transform upper case letters to smaller case letters. ………………..………..………………………………………………………… ……………………………………………………………………………………

62

……………………………………………………………………………………


5)

Write a program to print the Fibonacci series. ………………..………..…………………………………………………………

Writing a Programme in ‘C’

…………………………………………………………………………………… …………………………………………………………………………………… 6)

Write a program to determine the grade of the student; if marks are >= 75 grade should be A, if marks are >=60 grade should be B otherwise C. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

7)

Write a program to print factorial of the number entered by the user, without using function. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

8)

Write a program to find six letter words in a text. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

9)

Use switch statement to produce the menu card of a restaurant, the program should ask the user about its choice and then tell the user about the dishes available. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

10) Write a program to transform the time entered in minutes in to the format Hours: Minutes. ………………..………..………………………………………………………… …………………………………………………………………………………… …………………………………………………………………………………… 11)

Write a program to transform the height entered by the user in feet’s in to inches. ………………..………..………………………………………………………… …………………………………………………………………………………… …………………………………………………………………………………..

12)

Write a program to find the roots of a quadratic equation. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

2.5.5

Break and Continue

Break : The breakstatement will move control outside a loop or switch statement. Stylistically speaking, breakhas the potential to be a bit vulgar. It's preferable to use a straight whilewith a single test at the top if possible. Sometimes, you are forced to use

63


Lab Manual - 1

a break because the test can occur only somewhere in the midst of the statements in the loop body. To keep the code readable, be sure to make the break obvious -forgetting to account for the action of a break is a traditional source of bugs in loop behaviour. while (<expression>) { <statement> <statement> if (<condition which can only be evaluated here>) break; <statement> <statement> }// control jumps down here on the break The break does not work with if. It only works in loops and switches. Thinking that a break refers to an if when it really refers to the enclosing while has created some high quality bugs. When using a break, it's nice to write the enclosing loop to iterate in the most straightforward, obvious, normal way, and then use the break to explicitly catch the exceptional, weird cases. Program 11: Program to Demonstrate Break Statement #include<stdio.h> main() {int x=0; for(; ;) { if(x>=10) break; else printf(“%d \t”, x++); } printf(“that’s all friends ! \n”); } Continue : The continue statement causes control to jump to the bottom of the loop, effectively skipping over any code below the continue. As with break, this has a reputation as being vulgar, so use it sparingly. You can almost always get the effect more clearly using an if inside your loop.

64

while (<expression>) { ... if (<condition>) continue; ... ... // control jumps here on the continue


Program 12: Program to demonstrate continue statement

Writing a Programme in ‘C’

#include<stdio.h> main() {int x; for(x=1;x<6 ;x++) { if(x = = 3) continue; else printf(“%d \t”, x); } printf(“that’s all ! \n”);}

2.5.6

Switch Statement

The switch statement is a sort of specialized form of ifused to efficiently separate different blocks of code based on the value of an integer. The switch expression is evaluated, and then the flow of control jumps to the matching const-expression case. The case expressions are typically int or char constants. The switch statement is probably the single most syntactically awkward and error-prone features of the C language. Syntax of this control structure is as follows : switch (<expression>) { case <const-expression-1>: <statement> break; case <const-expression-2>: <statement> break; case <const-expression-3>: case <const-expression-4>:

// here we combine case 3 and 4

<statement> break; default: <statement>

// optional

} The classic example of the ternary operator is to return the smaller of two variables. Every once in a while, the following form is just what you needed. Instead of.. ,,, The syntax includes break statement, however, there is one more statement which is continue, we will discuss them afterwards. 65


Lab Manual - 1

Each constant needs its own case keyword and a trailing colon (:). Once, execution has jumped to a particular case, the program will keep running through all the cases from that point down -- this so called "fall through" operation is used in the above example so that expression-3 and expression-4 run the same statements. The explicit breakstatements are necessary to exit the switch. Omitting the breakstatements is a common error – it compiles, but leads to inadvertent fall-through behaviour. Program 13: Program to count number of vowels, commas, and periods; using Switch #include<stdio.h> main() { int c, vowel, comma, period; vowel=comma=period=0; while((c= getch()) != ‘$’) switch(c ) { case ‘a’: case ‘A’: case ‘e’: case ‘E’: case ‘i’: case ‘I’: case ‘o’: case ‘O’: case ‘u’: case ‘U’: vowel++; break; case’,’: comma++; break; case ‘.’: period++; break; } printf(”VOWELS=%d\n”,vowel); printf(”COMMAS=%d\n”,comma); printf(”PERIOD=%d\n”,period); }

66


2.6 COMPLEX DATA TYPES

Writing a Programme in ‘C’

We cannot only restrict ourselves to the data types given, their might be requirements of defining the user defined data types, a collection of say 100’s of same type of data etc. In order to work with that, we need to have the knowledge of complex data types, they are classified as: 1. Structures 2. Arrays a. Multidimensional Arrays b. Arrays of Structures 3. Strings 4. Pointers 5. User Defined Type Declaration Now, in this section, we will discuss these complex data types

2.6.1

Structures

C has the usual facilities for grouping things together to form composite types, this facility is given through the arrays and structures (also called records).We will discuss structure here, keyword struct is used for the purpose. For the sake of understanding the format of structure, following definition declares a type called "struct student" where struct is the keyword and student is the name of the structure it has three fields of different types named "roll_number",”percentage”and "grade", concentrating on the data types of the field you will appreciate the feature because now we are clubbing up the data of different types in to one form, which is in our control and this is the beauty of C. If you forget the semicolon at the end of the curly braces, which is the end of the structure definition then it tends to produce a syntax error in whatever thing follows the struct declaration. struct student { int roll_number; float percentage; char grade; };

This declaration introduces the type struct student (both words are required) as a new type. C uses the period (.) to access the fields in a record. You can copy two records of the same type using a single assignment statement, however == does not work on structs.

67


struct student X,Y X.roll_number = 1; X.percentage = 89; X.grade = ‘B’; Y..roll_number = 11; Y.percentage = 98; Y.grade = ‘A’;

Lab Manual - 1

Program 14 : Program to take record of the student, like its roll number, name, marks, using structures #include<stdio.h> struct rec { int roll; char name[20]; int marks; }; main() { struct rec student; clrscr(); printf("\n enter name and roll no of students \n"); scanf("%d %s", &student.roll, student.name); printf("\n enter marks"); scanf("%d",&student.marks); printf("\n\n entered details are:\n"); printf("%d \n %s \n %d",student.roll,student.name,student.marks); } Note : we can have array of structures

2.6.2

Arrays

The simplest type of array in C is one which is declared and used in one place. There are more complex uses of arrays which we will address later along with pointers. The following declares an array called scores to hold 100 integers and sets the first and last elements. C arrays are always indexed from 0. So the first int in scores array is scores[0] and the last is scores[99] as shown in Figure 1. int scores[100] ; scores[0]=13; // set first element scores[99]=42;// set last element

68


Writing a Programme in ‘C’

Figure 1: Example of an Array

It's a very common error to try to refer to non-existent scores[100]element. C does not do any run time or compile time bounds checking in arrays. At run time the code will just access or mange whatever memory it happens to hit and crash or misbehave in some unpredictable way thereafter. "Professional programmer's language." The convention of numbering things 0..(number of things – 1)pervades the language. Program 15 : Program to read a string #include<stdio.h> main() { char name[20]; scanf(“%s”, name); printf(“your name is : %s”, name); } Program 16 : Program to find average of 5 numbers, using arrays #include<stdio.h> main() { int i,sum=0,num[5]; for(i=0; i<=4 ;i++) { scanf(“%d”,num[i]); sum=sum+num[i]; } printf(“Average = %d”, sum/5); } Multidimensional Arrays The following declares a two-dimensional 10 by 10 array of integers, in the same manner we can define more dimensions of the array , here the first and last elements are initialized to be 13.

69


Lab Manual - 1

int board [10][10]; board[0][0] = 13; board[9][9] = 13; The implementation of the array stores all the elements in a single contiguous block of memory. The other possible implementation would be a combination of several distinct one dimensional arrays that's not how C does it. In memory, the array is arranged with the elements of the rightmost index next to each other. In other words, board[1][8] comes right before board[1][9] in memory. (highly optional efficiency point). It's typically efficient to access memory which is near other recently accessed memory. This means that the most efficient way to read through a chunk of the array is to vary the rightmost index the most frequently since that will access elements that are near each other in memory. Program 16 : Program to find sum of all the numbers entered in a two dimensional array of size 5x5 #include<stdio.h> main() { int i,k,sum=0,num[5][5]; for(i=0; i<=4 ;i++) { for(k=0; k<=4 ;k++) { scanf(“%d”,num[i][k]); sum=sum+num[i][k]; } } printf(“SUM = %d”, sum); }

Array of Structures The following declares an array named "numbers" which holds 1000 struct fraction's. struct fraction numbers[1000]; numbers[0].numerator = 22; numbers[0].denominator = 7;

/* set the 0th struct fraction */

Here's a general trick for unraveling C variable declarations: look at the right hand side and imagine that it is an expression. The type of that expression is the left hand side. For the above declarations, an expression which looks like the right hand side (numbers[1000],or really anything of the form numbers[...]) will be the type on the left hand side (struct fraction). 70


Program 18 : Program to take records of 5 student, like its roll number, name, marks, using structures

Writing a Programme in ‘C’

#include<stdio.h> struct rec { int roll; char name[20]; int marks; }; main() { int i; struct rec student[4]; clrscr(); for(i=0; i<=4 ;i++) { printf("\n enter roll no. and name of students \n"); scanf("%d %s", &student[i].roll, student[i].name); printf("\n enter marks"); scanf("%d",&student[i].marks); } printf("\n\n entered details are:\n"); for(i=0; i<=4 ;i++) { printf("%d \n %s \n %d",student[i].roll,student[i].name,student[i].marks); } }

2.6.3

Strings

C has minimal support of character strings. For the most part, strings operate as ordinary arrays of characters. Their maintenance is up to the programmer using the standard facilities available for arrays and pointers. C does include a standard library of functions which perform common string operations, but the programmer is responsible for the managing the string memory and calling the right functions. Unfortunately computations involving strings are very common, so becoming a good C programmer often requires becoming adept at writing code which manages strings which means managing pointers and arrays. C string is just an array of char with the one additional convention that a "null" character ('\0') is stored after the last real character in the array to mark the end of the string. The compiler represents string constants in the source code such as "binky" as arrays which follow this convention. The string library functions (see the appendix for a partial list) operate on strings stored in this way. The most useful library function is strcpy(char dest[], const char source[]); which copies the bytes of one string over to another. The order of the arguments to strcpy() mimics the arguments in of '=' -- the right is assigned to the left. Another useful string function is strlen(const char string[]);which returns the number of characters in C string not counting the trailing '\0'. 71


Lab Manual - 1

Note : that the regular assignment operator (=) does not do string copying which is why strcpy() is necessary. See Section 6, Advanced Pointers and Arrays, for more detail on how arrays and pointers work. The following code allocates a 10 char array and uses strcpy() to copy the bytes of the string constant "pinky" into that local array. main() { char localString[10]; strcpy(localString, "pinky"); }

localString p

i

n

k

y

\0

x

x

x

x

0 1 2 ... The memory drawing shows the local variable local Stringwith the string "pinky" copied into it. The letters take up the first 5 characters and the '\0' char marks the end of the string after the 'y'. The x's represent characters which have not been set to any particular value. If the code instead tried to store the string "We enjoy languages which have good string support" into localString, the code would just crash at run time since the 10 character array can contain at most a 9 character string. The large string will be written passed the right hand side of localString, overwriting whatever was stored there.

72

Program 19 : Program to check that the string entered by user is palindrome or not main() { char str1[80],str2[80]; int i,j; clrscr(); printf("enter the string to be checked for palindrome\n"); scanf("%s",str1); j=0; for(i=strlen(str1);i>=0;i--) { //printf("%c",str1[i]); str2[j]=str1[i]; j++; }str2[j++]='\0'; if(strcmp(str1,str2)==0) printf("entered a palindrome\n"); }


2.6.4

Writing a Programme in ‘C’

Pointers

A pointer is a value which represents a reference to another value sometimes known as the pointer's "pointee".Syntactically C uses the asterisk or "star" (*) to indicate a pointer. C defines pointer types based on the type pointee. A char*is type of pointer which refers to a single char. A struct fraction*is type of pointer which refers to a struct fraction. int* intPtr;

// declare an integer pointer variable intPtr

char* charPtr;

// declares a character pointer --

/*Below we declare two struct fraction pointers (when declaring multiple variables on one /line, the * should go on the right with the variable) */ struct fraction *f1, *f2; Further, the pointers are used to point to a certain data object i.e., it stores the address, rather than the value of a given data object. Once, the address of the variable is stored in a pointer, its value can be accessed in an indirect manner. The pointers are declared by a type statement with a * appearing before the variable e.g. int *ptr or int* ptr both mean same. Now, the name ptr is now used to point to a variable by storing its address. Now to get the address of the variable, it has to be used with a unary operator & in the following manner : int *ptr; int a , b , c; a=25; -----ptr = &a ;

// ptr gets the address of a and not its value

b = ptr ;

//variable b is assigned the address stored in ptr

c = *ptr;

// variable b is assigned the value stored at the address stored in ptr

Note :

Since, the pointers are supposed to store the address of a variable or array, so, it is illegal to use it with constants and expressions i.e. , &(a+b), &25, &(a+25) are illegal.

A pointer can be assigned the value 0 to explicitly represent that it does not currently have a pointee. Having a standard representation for "no current pointee" turns out to be very handy when using pointers. The constant NULL is defined to be 0 and is typically used when setting a pointer to NULL. Since it is just 0, a NULL pointer will behave like a Boolean false when used in a Boolean context. 73


Lab Manual - 1

Program 20 : Program to demonstrate simple working of pointers main() { int a = 10 ,b, *ptr; ptr = &a; b = *ptr; printf(“Value of b = %d \n”, b); b = *ptr+5; printf(“New value of b = %d \n”,b); }

2.6.5

User Defined Type Declaration

C supports a feature known as “type definition” that allows user to define identifier that would represent an existing data. Two type of user defined data types are available in C language : •

typedef

enumerated(enum)

typedef, this user-defined data type identifier can later be used to declare variables. It takes the general form : Typedef type identifier; Where type refers to an existing data type and “identifier” refers to “new” name given to the data type. The existing data type may belong to any class of type, including the user-defined ones. Example typedef int X; typedef float Y; here x symbolizes int and y symbolizes float. They can later be used to declare variables as follows : X batch1, batch2; Y name1[100], name2[75]; Now, batch1 and batch2 are declared as int variables where as name1 and name2 are declared as 100 and 75 floating point array variables. 74


Writing a Programme in ‘C’

Example typedef struct fraction Fraction; Fraction fraction;

// Declare the variable "fraction" of type "Fraction" // which is really just a synonym for "struct fraction".

The following typedef defines the name Tree as a standard pointer to a binary tree node where each node contains some data and "smaller" and "larger" subtree pointers. typedef struct treenode* Tree; struct treenode { int data; Tree smaller, larger; };

// equivalently, this line could say

// "struct treenode *smaller, *larger"

The main advantage of typedef is that we can create meaningful data type names for increasing the readability of the program. enum, it is defined as follows : enum identifier {value 1, value 2, value 3, …….., value n}; The “identifier” is a user defined enumerated data type which can be used to declare variables that can have one of the values enclosed with in the braces (known as enumeration constants). After this definition, we can declare variables to be of this new type as below: enum identifier v1,v2,v3,…..,vn ; The enumerated variables v1,v2,…..,vn can only have of the values value1, value2, …..value n . The arguments of the following types are valid i.e. v1= value3; v5= value1; Example : enum year {January, February,…..,December}; enum year finance_year_start, finance_year_end; finance_year_start = April; finance_year end = march; if (finance_year_start = January) printf(“its not the start of financial year”); 75


Lab Manual - 1

Note : The compiler automatically assigns integer digits beginning with 0 to all the enumeration constants. That is, the enumeration constant value1 is assigned 0 ;value 2 is assigned 1, and so on. However, the automatic assignment can be overridden by assigning values explicitly to the enumeration constants. For example enum day {Monday=2, Tuesday, …., Sunday}; Lab Exercises 3 1)

Write a program to find the highest and lowest of all the elements of an integer array. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

2)

Write a program to sort the elements of an array. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

3)

Write a program to find sum, difference and product of two 2-D matrices. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

4)

Write a program to reverse the string entered by the user. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

5)

Write a program to find that the entered string is palindrome or not. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

6)

Write a program using structures that takes the details of the students roll number, name, marks in 4 subjects, calculate the percentage marks secured by the student and accordingly award the grade to the student. The output should show the roll number ,name , percentage, and Grade secured by the student. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

7)

76

Write a program using pointers to compute the sum of all elements stored in an integer array. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………


2.7 FUNCTIONS

Writing a Programme in ‘C’

A function is a self contained block of statements that perform a coherent task of some kind, for which it is designed. Writing functions avoid rewriting the same code again. The declared function can be called whenever required. Using functions it become easier to write programs and keep track of what they are doing. If the operation of a program can be divided in to separate activities, and each activity placed in a different function, then each could be written and checked more or less independently. Separating the code in to modular functions also makes the program easier to design and understand. Syntax: return data type function-name(parameters declaration) { local declaration statement list return( data); } Note : Function can be categorized in two ways : a. Library functions, and b. User defined functions Library functions are designed by compiler designers and these are stored on the disk example scanf, printf, getch etc. Functions that are not available in the disk, may be defined by the programmer are called user defined functions. important points for functions usage:

• • • • • •

Any C program contains at least one function, if the program contains only one function then it must be main() function. If there are more than one function in the C program then one and only one function must be main(), because execution of the program begins with ain(). The number of defined functions can be, any number, depending of programmers choice and logic. Each function in a program is called in the sequence specified by the function calls in main() After each function has done its job, control returns to main. When main() runs out of the function calls, the program ends. All C functions have state of perfect equality , except that the program execution begins with main( )., further full liberty is there that one function can call other. 77


Lab Manual - 1

2.7.1

Declaration and Definition of Functions

A function gets called (declared) when the function name is followed by semicolon. Example: main( ) { add(); } A function is defined when function name is followed by a pair of braces in which one or more statements may be present: Example : add( ) { Statement 1; Statement 2; } Examples regarding the basic working of functions and their return type management: Example 1 main() { display_msg(); } void display_msg() { printf(“this message is displayed by function”); } Example 2 main() { float a,b,c; a=10.6;b=20.2; c=average(a,b); printf(“average of a and b= %f \n”,c); } float average (float a, float b) { float z; z=(x+y)/2 return(z); 78

}


here in example 2 float is the return type of the data(this could be int, char,etc) which the function average should return after its execution. return (expression) is the statement which is used to return the value from the function. Further, if the function is expected to return nothing then use void as the return data type of the function as it is in example 1 above, and no return statement is required (or you can simply write return; i.e., no expression is to be given .

2.7.2

Writing a Programme in ‘C’

Characteristics of Function

1) Any function can be called from any other function. Even main() can be called from other functions. Example main( ) { massage( ); } message( ) { printf(“\n welcome to C”); main( ); } 2) Any function can be called any number of times. Example main( ) { message( ); message( ); } message ( ) { printf(“\n I am OK”); } 3)

The order in which the functions are define in a program and the order in which they get called need not necessarily be same. main( ) { message1(); message2(); } void message2( ) { printf(“\n open”); message1( ); }

79


Lab Manual - 1

void message1( ) { message2( ); printf(“\n close”); } Here message 1( ) is called before message 2( ). However, it is recommended that define the function in the same order in which they are called 4) A function can be called from other function, but a function can not be defined inside another function main( ) { printf(“\n this is main function”); multiply( ); /*This is wrong*/ { mult (int a , int b); int c= a*b; } } 5) A function can call itself. This process is called recursion. main() { int a, fact; printf(“\n enter any number”); scanf(“%d”, &a); fact(“%d”,&a); fact = rec(a); printf(“factorial value = %d”, fact); } rec (int x) { int f; if(x= =1) return(1); else f = x * rect (x -1); return (f ) }

2.7.3

Call by Value and Call by Reference

In general, the parameter passing in C is by value rather than by address, but passing the parameter by value generally creates ambiguity. So, the technique of call by reference came in to picture which maintains persistence in the data stored by the variables. To understand consider the example: Example : Call by Value main() { int a,b; 80


a=3; b=5; // or you can write scanf(“%d %d”, &a,&b); fun_abc(a,b); printf(“value of a , b ; inside main = %d , %d \n “, a,b”);

Writing a Programme in ‘C’

} fun_abc(int a, int b) { a=10; b=20; printf(“value of a , b ; inside fun_abc = %d , %d \n “, a,b”); return; } The output will be: value of a , b ; inside fun_abc = 10, 20 value of a , b ; inside main = 3 , 5 Ambiguity, note that, in above example although the values of the parameters a and b have been modified in the function but these are local to the functions. It is not reflected in the main program. So, the values in the main program remain unaltered. This form of parameter passing and calling is known as Call by Value. Example : Call by reference From the above example, we find that any parameter value changed in the function is not reflected in the calling function. But, if we want that the change should be reflected in the calling function then the parameters should be passed, as pointers to the data element (i.e., the address of the data element) and not the value stored in that data element. This will produce reference to the same address i.e., same storage location, when referred by the calling program and the function, thus the ambiguity is resolved. Such calls to function may look like fun_abc(&a,&b), now here the addresses of the variable a and b are passed to the function and not the value which was the case of call by value i.e., fun_abc(a,b). Further the declaration of the function will now be fun_abc(int *a, int *b) {-------} Note : In the case of call by value, we can only return maximum of one value by any function. However, in some situations it may be desired that the values to be returned through the parameters so that the changes can be reflected there by allowing more than one value to be returned by a function. In such situation, we need to pass the parameters to the function as a pointer to the data element rather than its value. So, that the same storage is referred by both the calling program and the function Let us rewrite the program written above for call by value, now by call by reference 81


Lab Manual - 1

Example : Call by reference main() { int a,b; a=3; b=5;

// or you can write scanf(“%d %d”, &a,&b);

fun_abc(&a, &b); printf(“value of a , b ; inside main = %d , %d \n “, a,b”); } fun_abc(int *a, int *b) { *a=10; *b=20; printf(“value of a , b ; inside fun_abc = %d , %d \n “, a,b”); return; } The output will be: value of a , b ; inside fun_abc = 10, 20 value of a , b ; inside main = 10 , 20 Note : Passing arrays a s parameter In order to pass array as an parameter, the name of the array is only desired to be passed as an argument to the function, because the name of the array represents the starting address (i.e., base address) of the array. Thus, pointers can be used to reference all the elements of the array in the function. Example : to read 10 integers in an array and use the function to return the average main() { int n[10], i ,a; for(i=0; i<=9 ; i++) scanf(“%d”, &n[i]); a=arr_avg(n,10); printf(“average = %d \n”, a); } arr_avg(int x[] , int y) { 82

// OR arr_avg(int *x , int y)


int b , i; b=0; for(i=0; i<y; i++) b=b+x[i]; b=b/y; return(b);

Writing a Programme in ‘C’

} Program 21 : Program to find factorial of entered number using functions main() { int n,m; printf(“Enter the number whose factorial is to be found : ”); scanf(”%d”,&n); m=fact(n); printf(“factorial of %d = %d”, n,m); } fact(int a) { int i,f; f=1; for(i=1;i<=a;i++) f=f*i; return(f); }

Lab Exercises 4 1)

Write a program to swap two numbers, demonstrate the swapping by using both call by value and call by reference. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

2)

Write a program using functions, to determine the simple interest and the compound interest that a person is going to earn if s/he is going to lend One lakh Rupees for 5 years at 15% rate of interest to Mr. X. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

3)

Write a program using functions, to compute the surface area of circle, square, rectangle, sphere. Hint - define a separate function for each Geometry. ………………..………..………………………………………………………… …………………………………………………………………………………… ……………………………………………………………………………………

83


Lab Manual - 1

2.9 SUMMARY C is a powerful language, using this you can do many miracles like; assembly language programming, embedded programming, Micro controller programming etc. Although the topics discussed in this unit are very fundamental ones but no doubt a strong building can only stand on a strong foundation. So, it is advised that you learn the concepts taught in this unit and apply the same to up bring your hidden C Programmer.

2.10 REFERENCES/FURTHER READINGS •

E Balagurusamy, Programming in ANSI C,Third Edition, Tata Mc-Graw Hill.

Yashwant Kanetkar, Exploring C, BPB publications.

Fundamentals Of Computers And Information Technology by M N Doja, Deep & Deep Publications

84

http://www.cprogramming.com/

http://inner-smile.com/

http://www.geocities.com/SiliconValley/Park/7113/

http://www.codearchive.com/


Word Processing

UNIT 3 WORD PROCESSING Structure 3.0 3.1 3.2 3.3

3.4

3.5

3.6

3.7 3.8

Page Nos.

Introduction Objectives What is Word Processing ? Word Basics 3.3.1

Start Word Program

3.3.2

Creating Documents

3.3.3

Saving and Closing Documents

85 86 86 87 87 90 92 94 94 99 102 103 107 110 113 113 115 117 119 119

Edit and Formatting 3.4.1

Text Formatting

3.4.2

Page Setup

3.4.3

Printing Documents

3.4.4

Paragraph Options

3.4.5

Bullets and Numbering

3.4.6

Checking Spelling and Grammar

Page Design and Document Management 3.5.1

Header and Footers

3.5.2

Inserting Cliparts and Picture

3.5.3

Creating Tables

Mail Merge 3.6.1

Data Sources & Main Documents

3.6.2

Starting & Editing the Main Document

Summary References/Further Readings

120 126 126

3.0 INTRODUCTION Office automation software packages are in huge demand and hence, very many companies are the arena of office automation, among them Microsoft is the leader offering MS office package, however, other office automation software’s are also there like star office, open office etc. The office automation packages are to facilitate the execution of office related tasks in an easy manner. Generally, office related tasks involve documentation management, presentations, mathematical calculations, E-mails, Websites management; and the package as a whole involves component for each of the foresaid task, desired to facilitate the official working. Among the mentioned tasks, the documentation part is handled by Microsoft Word which is an excellent program of MSOffice package. Now, you might be thinking that in which language this application program is written, undoubtedly it’s a variant of our Visual Basic, called VBA i.e., Visual Basic Assistant. If you don’t believe then after opening your word document as mentioned in section 3.2 below, just press ALT+F11 and you will find that a Visual Basic like environment is opened. Using VBA you can customize your document, to work according to your requirements. Although this unit is about the fundamentals, and VBA programming is out of the scope of this unit. But if you have interest in such tasks, just explore the internet, the world is yours.

85


Lab Manual - 1

The tools discussed in this unit are also small components of the programs. So, firstly learn how to use these tools then go to the depth of designing your tools. MS Word performs documentation related tasks such as creating, editing, formatting, managing and protection of our documents in very simple way. In this unit you will learn the basics of all these techniques. The end product of a creating document is usually a printed document. Before printing from Word for the first time, you must check that your printer setup is correct. And Word's Print Preview feature used before printing any documents, helps in checking that all its elements are in place. All these printing options have been explained in detail in this unit. Word is a fairly simple program to use for completing simple tasks. It may be difficult to learn complex features of word but you should explore the more advanced possibilities of Word at this stage.

3.1 OBJECTIVES The objective of this course is to help you understand how MS Word can be used to manage documents easily, quickly and effectively. By the end of this practical course, you will know how to do the following: • recognize and understand many of the functions in the Microsoft Word window; • create, save, open and close a document; • delete text and replace text; • format text i.e., font, size, colour, alignment, bullets, numbering, styles, line spacing, tabs etc., ; • edit text i.e., cut, copy, paste, find and replace etc., ; • working with tabs; • use different page views to examine the document; • format the document i.e., headers, footers, page breaks, page set-up etc., ; • use the drawing toolbar and insert images; • use the spelling, grammar, thesaurus and word count facilities; • perform a word count in the document; • use the help facility and preview and print the document; • creating and working with a table; and • creating multiple letters using mail merge.

3.2 WHAT IS WORD PROCESSING?

86

Word processor is the tool to perform different editing and formatting operations on the text and process is called word processing. This constitutes a fundamental difference between a typewriter and word processor. The earliest word processors were electric typewriters with a tape recorder that could be edited. They were first used for automatic typing of letters. Later, they were used to playback material that was typed correctly when corrections were added. The "manual" way, at the time, was to have a typist type something, have it proofread, and then retype it with corrections, hoping that no new errors were introduced with the retyping. In addition to simply storing documents for later manipulation and retrieval, modern word processing software applications offer general features such as: spelling and grammar checks, thesaurus, word counts and search-and-replace functions. With these capabilities among the major word processing packages, such as Microsoft Word, WordPerfect (Corel Corporation), and Word Pro (Lotus Development Corporation).


Microsoft Word is a word processor program from Microsoft. Richard Brodie originally wrote it for IBM PC computers running DOS in 1983. Further versions were created for the Apple Macintosh (1984), SCO UNIX, and Microsoft Windows (1989). Further it became part of the Microsoft Office suite as Microsoft Word. Microsoft Word is an essential and excellent tool for the creation of documents. Its ease of use has made Word one of the most widely used word processing applications currently on the market. Therefore, it's important to become familiar with the various facets of this software, since it allows for compatibility across multiple computers as well as collaborative features.

Word Processing

3.3 WORD BASICS This section covers the basic details of MS-WORD. It will provide you step by step procedure for starting, creating saving and closing ad document in the WORD.

3.3.1

Start Word Program

To open the Microsoft Word application you can (a) Double click on the Microsoft Word icon (as given below) on the desktop.

(b)

Open Microsoft Word from the Start menu (Start Program Microsoft Office Microsoft Word) as shown in the Figure 1.

Figure 1: Open Microsoft Word

87


Lab Manual - 1

When Word opens, a blank document with name Document1 will appear similar to Figure 2. Window Control Buttons

Standard Toolbar

Formatting

As you can see in figure 2; A bar at the top of a document shows the name of MS-Office program (like Excel, Word) and document.

This is Your Working Area

View Buttons Drawing Toolbar Status Bar

Figure 2 : Components of Word Document

Note : Sometime it may happen that the word will not show these above given toolbars, if you want to bring them on your screen also then as shown in following Figure 3 go to the View menu which is given on 3rd position of your menu bar, choose Toolbars and ensure that the Standard, Formatting and Drawing toolbars are all selected.

MS-Word provide us different toolbars, those you can select according to your need. We advise you not to select those toolbar, which you don’t need at present.

Figure 3 : Different Toolbars in Word

88


Word Processing

The Microsoft Word window contains several menus and toolbars. Menus and toolbars are used to give instructions about what you want to do. Some of these are detailed as follows: Menu Bar : A menu gives a list of commands. Most menus are located on the menu bar at the top of the applications as given Word window. This menu contains drop menus, which allow the user to access all of Microsoft Word’s functions. The functions can be accessed using either the mouse or the keyboard button. Standard and Formatting Toolbar: Standard toolbar contains icons, which allow the user to perform common tasks such as save, print, copy and paste etc. where Formatting Toolbar contains icons which perform variety of formatting functions such as changing fonts and font size, choosing headings, justifying text, modifying text colour etc. These icons are shown in the following Table 1 with the use of these icon and associated action: Table 1: Meaning of different icons in the Standard and Formatting Toolbar

Name

If you want to use email option through word so you must have proper MSOutlook (another MS-Office program) connection and configurations.

Icon

You know all office programs contain almost common screen elements and toolbars.

Use and Description of Icon

New Blank Document

Creates a new, blank file based on the default template selected by the user.

Open (File menu)

Use to open a file.

Save (File menu)

Saves the active file with its current file name, location, and file format.

Mail Recipient

Sends the contents of the document as the body of the e-mail message.

Print (File menu)

Prints the active file or selected items. To select print options, on the File menu, click Print.

Print Preview (File menu)

Display the print preview and show how it will look when you print it.

Spelling and Grammar (Tools menu)

Checks the active document for possible spelling, grammar, and writing style errors, and displays suggestions for correcting them.

Cut (Edit menu)

Cuts the selection from the active document and places it on the Clipboard.

Copy (Edit menu)

Copies the selection to the Clipboard.

Paste (Edit menu)

Inserts the contents of the Clipboard at the cursor position.

Format toolbar)

Painter

(Standard

Copies the format from a selected object or text and applies it to the object or text you click.

Undo (Edit menu)

Undo your last command or action.

Redo (Edit menu)

Reverses the action of the Undo command. Inserts a new hyperlink or edits the selected hyperlink.

Hyperlink

Tables and Borders

Displays the Tables and Borders toolbar, which contains tools for creating, editing, and sorting a table and for adding or changing borders to selected text, paragraphs, cells, or objects.

Zoom

Enlarge the display of the active document according to the given % size.

Office Assistant

The Office Assistant provides Help topics and tips to help you accomplish your tasks.

89


Lab Manual - 1

Drawing Toolbar : This toolbar allows the user to draw and edit objects (like images graphics, clip art etc) in a document. Status Bar : This displays important document information to the user relating to page number, location of insertion point on the page etc. There are also additional features on the status bar such as OVR, which allow the user to ‘overtype’ or replace existing characters when typing. As shown in Figure 3, there are a number of other toolbars available in Microsoft Word. To show or hide the toolbars, click on the View menu and select Toolbars. This shows a list of all toolbars available to use in the Microsoft Word application.

3.3.2

Creating Documents

There are different ways for creating new documents, opening existing documents, and saving documents in MS Word. All these are further explained in this unit. Whenever you want to type something, you need to create a new document (or open old document), like we take a new paper from our notebook. Lets see how can you create a new document in word. To create a new document do the following steps: 1)

Choose File New from the menu bar. OR From the File menu, choose New. A New dialog box should appear similar to given Figure 4.

As you can see in figure 4, you have an option to select the kind of document you like to make for example letter, publication, report etc.

Figure 4 : New Document Options

90


2)

Confirm that the General tab is selected and the Blank Document icon is highlighted. Now click OK, a new document window should appear as given in Figure 4 above. OR Click the New Document button on the menu bar. OR Just press CTRL+N on your keyboard.

Word Processing

When you click the New button on the Standard toolbar, you get option of creating a document such as memo, letter, report, or resume, one can often save time by using one of the wizards or templates that come with Word. When you will do practical from your own, you will find that whenever a new document is open, word gives it a temporary name “Document 1”. If we open another new document then it would be named “Document 2” with the next “Document 3” and so on. The next step is to enter the text for the document. How to open an existing document? To quickly open one of the last documents you worked on, choose it from the bottom of the file menu. To open a document, click the Open button on the Standard toolbar. When the dialog box appears, select the document in the File Name box (Windows) and then choose the OK button. Choose File Open from the menu bar, Figure 5 will appear on your screen.

Figure 5 : Open an Existing Document

Click the Open File button on the menu bar. OR Press CTRL+O on the keyboard. Each the above method will show the same Open dialog box as shown in Figure. You can choose the file and click the Open button to open the file.

91


Lab Manual - 1

3.3.3 Make a habit of saving your document after each paragraph, as Word may stop abruptly due to hardware or software problem.

Saving and Closing Documents

To save a document on disk, click the Save button on the Standard toolbar. When you save a document for the first time, Word displays the Save As dialog box so that you can type a name for the document. How to save a document?

It is good practice to choose a filename with eight characters or less, as additional letters may not be visible.

You can save your document in different format like Web Page, Text format, Rich Text format, Document templates using Save As option.

1. Select File Save from the menu bar. 2. Select File Save As from the menu bar.

You must be interested to know that what is a difference between Save and Save As option? The main difference is that the Save option will simply overwrite your existing file, whereas Save As will give you the chance to choose any of the options/format given in its dialog box. 3. Click the Save button on the standard toolbar. 4. Press CTRL+S on the keyboard. How to close a Document? When finished working in Word close the active document and then quit Word by choosing Exit (Windows) from the file menu. To work on another document in Word, close the active document by choosing Close from the file menu and then open the other document. Also, several documents can be open at the same time. To work in a particular document, click anywhere in its window, or select the document name from the window menu. To close the current document by you can either select File Close or click the Close icon you can locate it on your standard toolbar. If you are prompted with a dialog box asking, “Do you want to save the changes you made to document1.doc?� it means you have not saved the file. Think always before Clicking on No.

Remember View options will not change your document at all. It changes only the appearances. As when you see a building from front view it appears different and when you see it from top it is different, but actually the building is same.

92

Document Views Word provides several ways to view a document: 1. Normal view 2. Print layout view 3. Web layout view 4. Outline view


1)

Normal View : It is the preset view in Word. It shows a simplified version of a document. It’s the best all-purpose view for typing, editing, and formatting text, and for moving around in a document.

Word Processing

To switch to normal view, click the Normal view button on the horizontal scroll bar, or choose Normal from the view menu. Normal view is preferred for most of heavy-duty text entry and editing. Normal view keeps repagination and screen redraw delays to a minimum. It shows the text as it is typed and displays graphics where they are inserted. It does not show side-by-side column positioning, footers, headers or the printing position of framed items. Columns are shown at their actual width, but not sideby-side. Automatic page breaks are shown as dotted lines. Manual page breaks, if they are defined, are shown as darker lines containing the words Page Break, while section breaks are double dark lines with the words end of section, and so on. 2)

Print Layout View : In Normal view, you can only see the one column formatting option which is the default. To view multiple columns on screen, you need to switch to Page Layout view, or look at the document in Print Preview. Page layout view displays the layout of each page in a document as it will look when printed. The vertical and horizontal ruler allow you to see precisely where things are positioned on the page. Page layout view is useful when you are working with columns, or to check the final appearance of the document, and make last minute changes to the text formatting and layout. In a page layout view, text and graphics are positioned where they will print. Headers and Footers can be both seen and edited. Page breaks, whether automatic or forced, are represented by new pages on the screen rather than by dashed lines in the text.

3)

Web layout view : Web layout view is similar to above given print layout view, only it refers to web page. It works when you are creating a Web page or a document that is viewed on the screen. In Web layout view, you can see backgrounds, text is wrapped to fit the window, and graphics are positioned just as they are in a Web browser.

4)

Outline View : If the document is properly formatted, switching to outline view allows to quickly navigate and reorganize even large, complex documents. Outline view allows you to see the entire contents of the document, just chapter heading or just section headings, and so on. In outline view, you can break a document into sections to see only the main headings or expand it to see the entire document. This view makes it easy to scroll or move text a long distance or to change the hierarchy of topics. To scratch to outline view, click the outline view button on the horizontal scroll bar, or choose outline from the view menu. 93


Lab Manual - 1

3.4 EDIT AND FORMATTING Once you learnt about creating document successfully now, you should get familiar with different editing and formatting aspects of a document. This section will help you in editing and formatting of your document.

3.4.1

Text Formatting

Adding Text To enter text, you need to start typing on keyboard; whatever you type will appear where the cursor is blinking. You can move the cursor by arrow buttons or using mouse. The keyboard shortcuts listed below in Table 2 are also helpful when you are typing the text in a document: Table 2: Keyboard Shortcuts in Documents Keystroke

Action in Document

HOME

Beginning of the line

END

End of the line

CTRL+HOME

Top of the document

CTRL+END

End of the document

Deleting, Selecting and Formatting Text If you make a mistake in your text, to delete text we can use the BACKSPACE and DELETE keys. Backspace will delete text to the left of the cursor and Delete will erase text to the right. To delete a large selection of text, highlight that portion and press the DELETE key. To change any attributes of text in your document first highlight that portion then select the text by moving mouse over that text or hold down the SHIFT key on the keyboard while using the arrow buttons to highlight the text. In table 3 are the shortcuts for selecting a portion of the text: Table 3: Shortcuts for Selecting a Portion of the Text Remember to deselect the text, you can click anywhere outside of the selection on the page or press an arrow key on the keyboard.

Text Portion

Selection method

Whole word

Double-click within the word

Whole paragraph

Triple-click within the paragraph

Whole document

Choose Edit Select All or press CTRL+A

The formatting toolbar is the easiest way to change many attributes of text. If the toolbar is not available on your screen, select View Toolbars and select Formatting. 94


Word Processing

Figure 6: Formatting Toolbar

All the tools of formatting are discussed below from left to right of the formatting toolbar. Style: You can select different styles on document in this. Font: Click the arrowhead to the right of the font type box to view the list of fonts available. Scroll down to the font you want and select it by clicking. Font Size: Click to enter a value for the font size or click the arrowhead to view a list of font sizes available. Font Style: You can use these buttons to bold, italicize, and underline text. Alignment: You can give aligning in text to the left, center, or right side of the page or it can be justified across the page. Numbered and Bulleted Lists: This is used to give numbering or bullets in the text (in heading or subheadings of text) Increase/Decrease Indent: Change the indentation of a paragraph in relation to the side of the page. Outside Border: Add a border around a text selection. Highlight Color: Use this option to change the color behind a text selection. Text Color: This option changes the color of the text. The color shown on the button is the last color chosen. The Font dialog box as given in Figure 7 allows you to choose from a larger selection of formatting options. You can select it as Format Font from the menu bar.

As you can see in figure 7 you have two more options named Character Spacing and Text Effects. You can try these options on a sample text.

95


Lab Manual - 1

Write =Rand() and press Enter. Check what text is duplicating and how many times? Find what is special about this text?

Figure 7: Font Dialog Box

In this toolbar you can have the preview of whatever effect you want to enforce on your text, you can check the implementation of different type effect given above. Feel free to experiment with various text styles and option. You can always undo your last action by clicking the Undo button or selecting Edit Undo. Cut, Copy and Paste of text Two different editing functions can be performed using the Cut, Copy and Paste functions in Microsoft Word. • Use Cut and Paste to move a piece of text in a document. • Use Copy and Paste to duplicate a piece of text in a document. Moving Text Select any word in the document. Select Edit Cut from the menu bar or click the Cut button on the standard tool bar, or press CTRL+X . The word will disappear. Do not worry, the word is not lost. It is stored in a temporary storage area called the Clipboard. Click Edit Paste from the menu bar, or click the Paste button on the standard toolbar, or press CTRL+V, the word will reappear in the text. Duplicating Text Select any word in the text. choose Edit Copy, or click the Copy button on the standard toolbar, or press CTRL+C to copy the text to the clipboard. Unlike the Cut function, the word remains visible. However, a copy of the word is also stored on the Clipboard. Place the cursor after the word and select Edit Paste from the menu bar, or click the Paste button on the standard toolbar, or press CTRL+V, the selected word should now be duplicated in the text.

Using MS-Word Help When you want any assistance or help regarding any feature and function of MS-word. You can use either of the following option. 1. Press F1 OR 2. Select Help from Menu Bar and Click Microsoft Word Help. OR 3. From Formatting Bar, Click Microsoft Word Help Button.

96


When you have a question about a Microsoft Office program, you can ask the Office Assistant. For example, to get Help about “duplicating text”, type it.

Word Processing

If the correct topic doesn't appear in the Assistant balloon, click None. You will get suggestions on how to phrase a question to the Office Assistant or how to narrow your search by using keywords. The Assistant automatically provides Help topics and tips on tasks you perform as you work — before you even ask a question. For example, when you write a letter, the Assistant automatically displays topics to help you create and format a letter. The Assistant also displays tips on how to use the features in the Office programs more effectively. Click the light bulb next to the Assistant to see a tip. Just click Microsoft Word Help on the Help menu. If the Assistant is turned on, it appears. If the Assistant is turned off, the Help window appears. To type a question in the Help window, click the Answer Wizard tab. To scroll through a table of contents for Help, click the Contents tab. When you want to search for specific words or phrases, click the Index tab. •

To see a ScreenTip for a menu command, toolbar button, or screen region, click What's This? on the Help menu, and then click the item you want information about.

To see a ScreenTip for a dialog box option, click the question mark button in the dialog box, and then click the option. (If you don't see the question mark button, select the option and then press SHIFT+F1.)

To see the name of a toolbar button, rest the pointer on the button until the name appears. 97


Lab Manual - 1

Hide, show, or turn off the Office Assistant You can temporarily hide or show the Office Assistant while you're working in Microsoft Word. You can also turn off the Office Assistant for your entire Word session and use only the Help window. How to get Help without the Office Assistant. To temporarily hide or show the Office Assistant follow the steps: 1. On the Help menu, click Hide the Office Assistant or Show the Office Assistant. 2. Turn off the Office Assistant for an entire Word session 3. In the Assistant balloon, click Options. 4. If the Assistant balloon isn't visible, click the Assistant. On the Options tab, clear the Use the Office Assistant check box. To turn on the Assistant at any time, click Show the Office Assistant on the Help menu. You can remove the Assistant if you don't want to use it any more. Lab Exercises 1 a) Bring ‘WordArt toolbar’ on your Word Screen and place it with other toolbars. b) Create a document in which write a letter to your friend, send the letter with the name of your friend. Use different colors in the body of letter, starting & end of the paragraph. c) Using Resume Wizard, Create your resume for applying the post of software Engineer. Note: From File New, choose other document and select resume wizard. d) Check and write the differences between the normal view, print layout view, web layout view and outline view. e) Create the following characters “A2log2C” having superscript and subscripts characters as shown.

A2log2C f)

Type the following lines in the document as shown in the given box below, and save the file with name “Insert Special Symbols”.

1. Click Insert from the Menu bar and then click Symbol. 2. Choose the Symbols tab. a. From the Font drop down list select the style of symbols you would like to insert. b. Click on the symbol that you wish to insert, and then click Insert. 98


Word Processing

3.4.2

Page Setup

You should start each new project after duly thinking about the document’s overall design and final appearance. Word for windows gives you on-screen clues about how your document will look on paper. If you give Word some basic information, such as the paper size and the kind of printer you will be using, it can show you line endings, page endings, the relative size and placement of text, graphics, margins and so on. In order to do this, Word needs some information from you, such as the paper size and the kind of printer you will be using. The Page Setup dialog box, allows you to give Word all the information it needs. The Page Setup command in the file menu enables to set the paper size, page orientation (portrait or landscape), the working of headers and footers, and similar options before you began a document. But you can easily change these and other settings at any time. You can also use sections and set different options for each section. Paper Size & Page Orientation The paper size tab in the Page Setup dialog box can be used for selecting the paper size and the options that are available depend on the capabilities of the printer you selected. To use a custom paper size, type the dimensions of the paper you want to use and also be sure that the printer is capable of feeding the custom paper size through its printing mechanism. Once you specify the size of the paper on which you will print the document, Word calculates margins by measuring in from the edges of the paper. Page orientation can be vertical (Portrait) or horizontal (Landscape).

99


Lab Manual - 1

Figure 8: Page Setup Dialog Box Showing Paper Size Options

To select the paper size and page orientation follow these steps: 1) Select the text you want to have a different paper size or page orientation. 2) From the File menu, choose Page Setup and then select the Paper size tab. 3) Select the paper size on which you want to print and the page orientation. 4) In the Apply To box, select how much of the document you want to print on the selected paper size or in the selected orientation. Then click the OK button. Also it is possible to change the default page size and orientation. Like, if you often print on paper other than the standard letter size - 8.5×11 inches or if you use landscape orientation more frequently than portrait orientation, you can save time by changing the default settings. After specifying the new settings, choose the default button. When Word asks you in case you want to change the default, choose the Yes button. Word saves the new default settings in the template attached to the document. Page Margins Margins determine the distance between the text and the page of the paper. In Word, text and graphics are normally printed inside the margins while headers, footers and page numbers are printed in the margins. Word gives you three ways to set margins. The most straightforward method is to use, the Margins portion of the Page Setup dialog box, reached with the File → Page Setup command.

Figure 9 : Page Setup Dialog Box Showing Margins Options

100

You can also drag margins using the rulers in Print Preview. This lets you see the results of margin changes after a slight repagination delay.


Finally, you can drag new margins with the rulers in Page Layout view. The margin

Word Processing

brackets are located on the ruler. Let’s look at all three techniques, starting with the dialog box. Follow these general steps to change margins from within the Page Setup dialog box: 1) Place the insertion point on the page where you want margin settings to be changed (unless you plan to see the Whole Document choice). 2) Choose File → Page Setup. 3) If need be, change paper size and orientation by using the Paper Size tab. 4) Switch to the Margins tab if it is not already displayed. 5) Current settings are shown in the various margin dimension boxes. 6) Type the dimensions you desire, or click the little triangles to increase and decrease settings. The Preview will change as you work. 7) When satisfied, click OK. Dimensional settings in most of Word dialog boxes can be expressed in inches (in), points (pt), centimeters (cm), picas (pi), and, frequently lines (li). For instance, to set a top margin’s height to 12 points, you would type 12pt in the Top margin box, to set a one-and-one half line top margin, you’d type 1.5li, etc. While you can type other measurements, Word will convert them to the default measurement when you close the dialog box. You change the default measurement in the General tab of the Options dialog box (Tools → Options). Mirror Margins Select the Mirror Margins feature in the Margins tab of the Page Setup dialog box (File → Page Setup) when you want different left and right margin widths and your final output will be two-sided. Word makes inside margins of odd and even numbered pages the same size; and does the same with the outside margins of odd and even pages. This is how you get white space on the appropriate side of even and odd, two-sided pages. When adjusting margins in Print Preview, if you’ve chosen the Mirror Odd/Even feature, display two pages in Print Preview so that you can see the different margins. Gutters position Gutter margins-additional white space in the inside margins-compensate for the paper tucked away in the binding of a two-sided book that would be unreadable. The gutter width, which you specify in the Margin tab of the Page Setup dialog box (File → Page Setup), reduces the text area. Instead of using gutters, you might simply want to increase the size of the inside margins to accommodate binding. 101


Lab Manual - 1

3.4.3

Printing Documents

Before printing a document, Page breaks and the overall appearance of the document is checked by choosing print preview from the File menu. To view the document one page at a time, and also edit the text more easily, choose Page Layout from the View Menu. When ready to print, click the Print button on the Standard toolbar.

Figure 10 : Print Dialog Box and Printing Options

While printing a document, you can: 1) Print the entire document or only specific pages. 2) Print summary information, annotations or list of styles, AutoText entries or key assignments. 3) Print a draft copy, which omits graphics to allow faster printing. 4) Set printing options, such as number of copies. You can also automatically create and print an envelope, using an address from a document or one that you type. You can either print directly on an envelope or store the information so that you can print the envelope later. The printer you can use affect the way Word prints and displays text on the screen. Before you print a document, you must install and select the printer you intend to use to print the document. Word displays a document as it will look when you print it. If you want to preview a document before you print it, use page layout view or print preview. In each of these views, you can make last minute changes to text formatting, page breaks and margins. 102


Line breaks and page breaks should be the same on the screen and in the printed

Word Processing

document. However, the fonts and view options you choose can affect the match between what you see on the screen and what appears on the printed page. Three kinds of fonts affect your work in Word: Scalable fonts, Printer fonts and Screen fonts. Use Scalable fonts, such as True Type fonts to ensure that what you see on the screen is what appears on the printed page. For using printer fonts, you must have a corresponding screen font and font size to display each font on the screen. If each screen font you use has a matching printer font, the screen display of the document will closely match the printed document. The three basic steps for printing a document are:

1) Connecting the Printer: Connect the printer either directly to your computer or to a network. 2) Selecting the Printer: Choose Print from the file menu then choose the Printer button and select the printer you want to use. 3) Print Preview and Printing: Click the Print button on the Standard toolbar. In Windows, Word prints one copy of the active document using the word default print settings. But it is better to check the preview of document before giving the print command. You can see the Preview of your document by clicking the Print Preview button on the standard toolbar or by selecting File Print Preview. When the document is ready to print, click the Print button from the Print Preview screen or select File Print.

3.4.4

Paragraph Options

In Word, a paragraph is any amount of text, graphics, object or other items that are followed by a paragraph mark. A paragraph mark is inserted each time while pressing the ENTER key. In order to change the formatting of a paragraph, select the paragraph and then apply the formats you apply. Paragraph formats affect the entire paragraph and new paragraphs keep the formatting of the preceding paragraph. Paragraph marks store the format of each paragraph. if the paragraph mark is deleted, the text in that paragraph becomes part of the next paragraph. To insert a new line mark, press Shift +↵ ↵ which pushes the text down to the next line, but does not create a new paragraph. To modify the appearance of paragraphs, use the ruler, the formatting toolbar and the Paragraph Dialog Box or one of Word’s paragraph formatting shortcut key combinations. The various ways in which the Paragraph formatting can be done is described in the following subsections:

103


Lab Manual - 1

Figure 11 : Components of Paragraph Dialog Box

Centering, Right Alignment and Left Alignment By default, the text in Word is left aligned. But these alignments can be changed. Indenting a paragraph enables it to set off from other text.

• • •

To indent paragraphs automatically, drag the top half of the triangular indent marker to the right to the desired position. Alternatively, you can select Format → Paragraph and enter a setting in the first line Indent box in the Paragraph dialog box. To increase or decrease indents by one Tab stop, use the Increase Indent and Decrease Indent button on the formatting toolbar. To create a hanging indent (an indent that sticks out beyond the paragraph), drag the top half of the triangular indent marker to the left to the desired position. You can also select Format → Paragraph and enter a setting for the first line indent box in the paragraph dialog box that is farther left than the indent of the paragraph as a whole.

Notice the difference between left and right margin and the paragraph indentations. The margins establish the overall width of the main text area and the space between the main text area and the edges of the page. 104


Left and right indents are measured from the left and right margins, respectively. The first line indent is measured relative to the left indent. The negative left-indent measurement for the text appears when the text runs into the left margin.

Word Processing

Tab Stops By default, the Tab Stops are set at 0.5-inch intervals from the left margin. The insertion point can be moved to the next tab stop in the current paragraph by pressing the TAB key. Use the ruler to set a tab stop at a particular position or to change the way text lines up at a tab stop. To set tab stops 1) Select the paragraph in which you want to set or change tab stops. 2) To set or change the tab alignment, click the Tab Alignment button at the far left of the horizontal ruler until the tab alignment is the way you want it to be. Table 5: Tab Alignment button

To select

Click

Left-aligned tab stops

L

Centered tab stops

⊼

Right-aligned tab stops  Decimal tab stops

⊼

3) On the ruler, click where you want to set a tab stop. Also you can set precise measurements for tab stops by using the Tabs command on the format menu.

Figure 12 : Tab Dialog Box 105


Lab Manual - 1

To move a tab stop, point to the tab marker and drag it to a new position. To clear a tab stop, drag the tab marker off the ruler. The spacing between the default Tab Stops can also be changed but this will affect only the active document. To do this, type or select the distance you want between the tab stops in the Default Tab Stops box and then click the OK button. Line Spacing Line Spacing determines the height of each line of text in the paragraph. The default (single line spacing) depends on the size of the font characters. Individual line spacing is easy to change. The indents and spacing tab of the Paragraph dialog box provides a drop-down for simple but effective control of the space between lines under most circumstances. The preview area demonstrates the relative effect of single, one-and-a half and double line spacing. Single spacing causes 12-point line spacing, 1½ line spacing is 18 points and double spaced lines will be 24 points apart. All these line spacing settings can be made by choosing the appropriate options from the Line spacing menu in the Paragraph dialog box. When we are working with paragraphs word provides special toolbar for formatting a paragraph you can also select it from Format Paragraph from the menu bar, when you select it the following figure will appear having following figure as given in figure: When you use these choices, Word will compensate for graphics, superscript and large or small type sizes. Paragraph Spacing Word enables each paragraph to give unique before and after spacing if you wish. The spacing settings can be in points (pt), inches (in), centimeters (cm) or lines (li). One advantage of adding space this way is that the spacing before and after paragraphs does not change the point size of your text. Another advantage is that you can use different spacing combinations for different purposes. Headings often have different spacing requirements for body text. For instance, you may require different before and after spacing designs for figures and figure captions as well. Also you can have unique spacing specifications as part of a style, making it easy to keep the look of your documents consistent. The Paragraph command on the format menu can be used to add space before and/or the paragraph. The other advantages of using the Paragraph command are:

106


1) You can make precise adjustments to the spacing between the various text elements. For example, you can use paragraph spacing to clarify the relationship between headings and body text.

Word Processing

2) If the paragraph is moved or deleted, its spacing goes with it. The paragraph doesn’t leave behind extra blank lines. 3) If you include spacing in the paragraph styles you use to format text, Word adds the space along with the other formatting. You need not add blank lines manually. Borders & Shading You can add borders, to any side of a paragraph, and you can add background shading using Format Borders and Shading as shown in the figure 13. You can also add borders and shading to ordinary text and to the paragraphs in table cells and frames.

Figure 13: Border and Shading Dialog Box

3.4.5

Bullets and Numbering

You can easily create a bulleted or numbered list by selecting a list and then clicking the Bullets button or the Numbering button on the formatting toolbar. Type the first entry and press ENTER. This will create a new bullet or number on the next line. If you want to start a new line without adding another bullet or number, hold down the SHIFT key while pressing ENTER. press ENTER twice when you are finished typing to end the list. You can use the Increase Indent and Decrease Indent buttons on the formatting toolbar to create lists of multiple levels.

107


Lab Manual - 1

To create a nested list, such as a numbered list inside of a bulleted list, first type the list and increase the indentation of the items that will make up the nested list by clicking the Increase Indent button for each item. Highlight the items and click the Numbered List button on the formatting toolbar. For example: •

Garden Tree Apple

Formatting Lists The bullet image and numbering format can be changed by using the Bullets and Numbering dialog box.

Figure 14 : Bullet and Numbering Dialog Box

Highlight the entire list to change all the bullets or numbers, or

Place the cursor on one line within the list to change a single bullet.

• • •

108

Access the dialog box by selecting Format Bullets and Numbering from the menu bar or by right-clicking within the list and selecting Bullets and Select the list style from one of the seven choices given, or click the Picture... button to choose a different icon. Click the Numbered tab to choose a numbered list style.

Click OK when finished. Lab Exercises 2 a. Do the following using the page setup dialog box. i. Set the paper size to A3. ii. Set the length and width to 19.59 cm and 18.56 cm respectively. iii. Set all margins (top, bottom, left, right and gutter) to 2.10 cm. iv. Set the gutter position to top


b.

What you need to write in page range when you want to take printout of the following pages: i. Pages 3 to 8 only ii. Page 2, 5, 9, 14 only iii. Only active page of word document

c.

How you can take print out when it should come on both sides of a page (front & back to it).

d.

Create a paragraph with line spacing “2” and use alignment as justification.

e.

Set your tab position to 1.3 inch.

f.

Create the border of your document to your page to 3D shadow border setting.

g.

Create the Border setting of your document using horizontal lines.

h.

Set the paragraph spacing 6 pt before and after.

i.

Show how you can make following Bulleting and Number in word. ( remember you need to create your own bullets as shown in the part (i) which having bullet name : first line , second line and third line ) (i)

(ii)

Word Processing

first line Garden second line Tree third line Apply

1.

Garden (i) (ii)

Tree Plant a) Flower b) Seed

Find and Replace Find and Replace allows you to search for specific text in your document. Word will find text whether it was typed in upper or lowercase. You can search for and replace text, specific formatting, and special items such as paragraph marks, fields, or graphics. You can also search for and replace all forms of a word (for example, replace “make” with “build” as well as “made” with “built”). To fine-tune a search, use wildcards (for example, search for “s?t” to find “sat” or “set”). To Find and Replace text: 1. Click the Edit menu select Replace 2. The box below will appear 3. Type the word you want to find the Find What box 4. Type the word you wish to replace it with in the Replace With box When finished, click Find Next to find the next occurrence of the word you are searching for. You can click Replace to replace the current word found, you can click Find Next to skip that word and go to the next occurrence or Replace All occurrences of the word you were searching for.

109


Lab Manual - 1

Figure 15 : Find and Replace Tool

Editing and Proofing Tools The editing and proofing tools in Word help to improve your writing and the readability of your text. These tools can:

• • •

Find and correct spelling errors. Automatically correct typing and spelling errors that you’ve specified. Locate possible grammatical or stylistic errors, suggest improvements and help you evaluate the readability of your text.

• • • •

Look up synonyms, antonyms, and related words. Automatically hyphenate text. Check text in other language. Display document statistics such as word count or paragraph count.

In this section we will discuss some of the important tool available in word.

3.4.6

Checking Spelling and Grammar

Spell check is one of the powerful features of MS-Word. It also provides to check the spellings of the entire document including the header, footer and the hidden text. Adding words to the dictionary is possible. The Spelling Check provides a convenient way of correcting spelling mistakes at your documents. It compares the words in your document against its own dictionary. You should always check your documents with the Spelling 110

Checker before you print them. To use the spelling and grammar checker, follow these


steps. Select Tools Spelling and Grammar from the menu bar. The Spelling and

Word Processing

Grammar dialog box will notify you of the first mistake in the document and misspelled words will be highlighted in red.

Figure 16 : Spell Checking

When the Spelling Checker locates a word it cannot find in the dictionary it stops, highlights the offending word, and display it on the “Not in Dictionary” line. You have the option to: Ignore its selection; Manually type in a correction to the word; Replace the word with a suggested word; Add the word to the dictionary. The “Suggestions” box lists possible alternatives to the word. If it cannot find a close match this box will be empty. To retain the word, choose Ignore and to ignore the change at all its occurrences in the document Choose Ignore All. To change the word, choose Change and to change the word at all its occurrences in the document choose Change All. To add the current selected word into the dictionary, choose the Add button. You have the choice to add the word to the default Word custom dictionary, or a new custom dictionary that you create. During a grammar check, Word identifies sentences that contain possible grammatical or stylistic errors and suggests improvements. For example, if you wrote “The project were completed by your team,” Word could question the grammar, first for subject-verb agreement and then for passive voice. Word also question style errors, such as wordiness and the use of clichés. 111


Lab Manual - 1

As long as the Check Grammar box is checked in the Spelling and Grammar dialog box, Word will check the grammar of the document in addition to the spelling. Follow these steps for correcting grammar: a)

If Word finds a grammar mistake, it will be shown as the spelling errors with green underline. Several suggestions may be given in the Suggestions box. Select the correction that best applies and click Change.

b)

If no correction is needed, click the Ignore button.

Figure 17: Grammar Checking

Synonyms Word has a new feature for finding synonyms. Simply right-click on the word and select Synonyms from the shortcut menu. From the list of suggested words, highlight the word you would like to use or click Thesaurus... for more options.

112

Figure 18: Finding Synonyms


Word Processing

Thesaurus The “Thesaurus” can be used to improve the precision and variety of your writing. It looks at the words you select and presents alternatives with similar meanings. You then have the option to select a word that better fits your needs. The Thesaurus cannot understand the context in which the original word is used, so the alternatives it offers are not always valid. It is for you to decide whether another word which you choose improves the meaning of the sentence. For some words, you may also find antonyms (words with opposite meanings) and related words. To use the thesaurus, select Tools Language Thesaurus from the menu bar or select it from the Synonyms shortcut menu as given above.

Figure 19 : Thesaurus

A list of meanings and synonyms are given on the windows. Double-click on the words in the Meanings box or click the Look Up button to view similar words. Double-click words in the Replace with Synonym box to view synonyms of those words. Highlight the word you would like to add and click the Replace button.

3.5 PAGE DESIGN AND DOCUMENT MANAGEMENT This section covers few advanced topic of WORD. To make your document more effective and impressive you would like to add few images, table or graphs in your document. In this section you can get procedures for creating header, footer, table etc.

3.5.1

Header and Footers

Headers and Footers are places to put repetitive information in a document’s top and bottom margins-headers print at the top, footers at the bottom. You can use headers and footers to print something simple on each page, such as you name, or something complex, such as a graphic. Stylized text, dates and automatic page numbering can all be included in headers and footers. 113


Lab Manual - 1

You can use identical headers and footers on all pages in your document, or you can specify different contents for each section of the document. Odd and even pages can have different designs if you wish. The first page of each document of each section can be unique.

Once headers and footers have been added to a document, it is possible to see and edit them in Page Layout view. They are also displayed in Print Preview, but when you attempt to open a header or footer in Normal view or Print Preview, Word switches you to Page Layout view and displays the Header and Footer toolbar.

Creating Basic Headers and Footers

To enter a header that repeats on all pages in your document: 1) Choose View → Header and Footer or double-click in the header area of the first page to be modified in Page Layout view or Print Preview. 2) Word will switch to Page Layout view if it is not already there and display the Header and Footer toolbar.

Figure 20 : Creating Basic Headers and Footers

3) Create and edit header text as you would do in any other text. You can paste graphics, apply styles, and otherwise format your work normally. 4) Use the automatic page-number, time-stamping, and date-stamping features described later in this chapter. 5) Double-click in the main document to return to work there.

114


You enter footers the same way as headers, except that you work in a Footer window.

Word Processing

The Layout tab of the Page Setup dialog box helps in:

Figure 21: Page Setup Dialog Box Showing Header and Footer Edges

1) Creating Different Headers and Footers for Odd and Even Pages 2) Creating Different Headers and Footers for the First Page

3.5.2

Inserting Cliparts and Picture

Inserting Clip Arts Clip arts are freely available artwork in digital form that can be used in a digital document. It provides artwork for creating interactive and attractive documents. It is available in Clip Gallery, which provides preview to a wide variety of pictures, photographs, sounds, and video clips that you can insert in your documents. To insert a clip go to menu bar, click Insert picture Clip Art or click on the clip art icon on the Drawing toolbar the following image will appear.

115


Lab Manual - 1

Figure 22: Different Categories in Clip Gallery

To add a clip art image/artwork from the Microsoft library to a document, follow these steps: 1) Click the category you want. 2) Click the picture you want, and then click Insert clip on the menu that appears.

116

Figure 23 : Different Options on Insert Clip Menu


Word Processing

3)

When you are finished using the Clip Gallery, click the Close button on the Clip Gallery title bar. Inserting Picture In the similar way to clipart you can also insert any image in your document if that image is available in your computer system. Follow these steps to insert a picture from an existing file: 1) On the menubar select Insert Picture From File. Following dialog box will appear.

Figure 24 : Different Options on Insert Clip Menu

1) Locate the picture you want to insert. 2) Double-click the picture you want to insert.

3.5.3

Creating Tables

Word’s Tables feature, enables you to arrange columns of numbers and text in a document without using tabs. It helps you to organize complex columnar information. Tables also provide a convenient way to present text in side-by-side paragraphs as in a resume, or to arrange text beside graphics. You can use them to create such diverse documents as forms, television scripts, financial reports, parts catalog, and resumes. You can insert tables anywhere you need those in Word documents. Word’s table feature and the terminology used to describe it, reminds you of a spreadsheet. Word tables consist of horizontal rows and vertical columns. You do the typing in areas called cells. Cells can contain text, numbers, or graphics. The text in cells is edited and embellished as usual with Word’s formatting toolbar and ruler. 117


Lab Manual - 1 COLUMNS

R O W S

Figure 25 : Table having 2 Columns and 4 Rows. A number of table specific features let you control the size, shape, and appearance of cells. Border and Shading features are available. It is also easy to insert and delete rows and columns. They can be created from existing text without needless retyping. Also the table feature can be used to organize information and then convert your table to text. Tables are used to display data and there are several ways to build them in Word. Begin by placing the cursor where you want the table to appear in the document and choose one of the following methods: Insert a Table There are two ways to add a table to the document using the Insert feature: Click the Insert Table button on the standard toolbar. Drag the mouse along the grid, highlighting the number of rows and columns for the table. Or, select Table Insert Table from the menu bar. Select the number of rows and columns for the table and click OK.

Figure 26 : Insert Table Options

118


Entering and Editing Text in a Table

Word Processing

You navigate, enter and edit table text just as you do any other Word text. The mouse or arrow keys are used to position the insertion point. The cells are thought of as miniature pages and the cell borders as margins. Type the text normally within these cells and Word will automatically wrap text within the cell as you reach the right edge Rows will automatically grow taller as necessary to accommodate your typing. To move from cell to cell within a table, either use the Tab key to go forward and Shift+Tab to go backward. Pressing Tab in the rightmost column will move down the insertion point to the beginning of the next row and pressing Shift+Tab past the leftmost column will move the insertion point to the end of the previous row. The familiar character formatting toolbar, ruler and menu features work in the same manner to all or selected characters in a table. A cell can contain more than one paragraph. Paragraph creation is done in the usual way and Word’s paragraph format apply to paragraphs in cells. Within a cell, you can have several different indent settings, line-spacing specifications styles. etc.

3.6 MAIL MERGE Word's Mail Merge feature is a quick and easy way for mass-producing form letters, envelopes, mailing labels, phone lists etc. By using Mail Merge, you can send the same letter to a number of people, without typing the original letter more than once. Word's Mail Merge feature lets you quickly create personalized correspondence and other documents by combining information (merging) information from two different files. Mail Merge feature can also be used to prepare other kinds of merged documents such as catalogs, parts lists, directory lists forms or invoices, print addresses on envelopes and mailing labels.

3.6.1

Data Sources & Main Documents

Data Sources are organized collections of information - databases-stored as Word tables. Word can also use data from other applications such as MS Excel or MS Access. After opening a data source in another application, make sure that the merge fields in your document match those in the data source. All data sources, no matter where they come from, contain records and fields. For example, an employee data source would contain one record for each employee. This record would contain multiples fields - one for the employee's first name, one for the middle initial, one for the last name, one for each part of the address and so on. The data source contains the information that can vary in each version of a form letter, such as the names and addresses. You can either open an existing data source or create a new one in Word. 119


Lab Manual - 1

Main documents as mentioned earlier contain the text of your project (the body of a letter), fields, and merge instructions. Main Documents can be used from earlier versions of Word or from other Applications. While using the Main document from other applications, open that documents in Word 6 and convert its contents to Word for Windows. However, field names and formatting from some applications may not translate well into Word for Windows format. Check the fields in your main document and adjust them if necessary before completing the merge or you can paste the main document into Word for Windows as plain text, then apply the formatting and centering the field names.

3.6.2

Starting & Editing the Main Document

Creating a merge main document, such as form letter, is a three-step process, as given in the Figure: 27 below. Step 1: To set up the main document, which contains the text, punctuation, and other items that remain the same in each version of the form letter. Step 2: To set up a data source, which contains the information that varies in each version. This can be done either by opening an existing data source or creating a new one. Step 3: To complete the main document by inserting merge fields and by typing or adding information you want to be the same in each form letter, such as the body of the letter, your address and your logs.

120

Figure 27: Main Window for Mail Merge


Step 1 : To Start the main document

i)

ii) iii)

Word Processing

Select the create button to start creating your main document. A list will drop down offering you four choices- Form Letters, Mailing Labels, Envelopes and Catalogs as shown in the figure . Select the type of main document you want. A dialog box appears offering you the choice of the active window or a new main document. Choose the Active Window button if the active window contain information for your main document or choose the New Main Document button if the active window doesn't contain any information for the mail merge.

Figure 28: Creating Main Document

Whichever button you choose, Word will return to the Mail Merge Helper dialog box and the space below the create button now lists the information you've entered so far-the type of merge and the main document to use. Step 2: Next, you need to specify the data source and arrange in it the fields that will be available to your main document for the merge. i)

Click the Get Data button to display a list of options for your data source.

ii)

If you already have a data source that you want to use, select Open Data Source or if you want to create a new one, select Create Data Source.

Creating a Data Source The Create Data Source dialog box that appears (Figure: 29) when you choose Create Data Source contains a list of commonly used field names under "Field Names in Header Row" box. The next step is to add field names in the data source. This can be done by selecting the field names from the Field Name in Header Row box or by adding the new ones to it. These field names can be upto 40 characters long and contain letters, numbers, and underscore (_). They cannot contain spaces and must start with a letter.

121


Lab Manual - 1

The following operations on the field names can be done: 1) To delete a category from the data source, select it and choose Remove Field Name button. 2) To add a category to the data source, type the new field name in the Field Name box and then choose Add Field Name button. 3) To change the order of field names, select a field name in the field names in Header Row box, and then click the up or down arrow at the right of the list until the field name is in the desired position.

Figure 29: Creating Data Source

When you finish creating the field names, choose the OK button. Word then displays the Save Data source dialog box. You save the new data source by giving a new filename to it. Word then displays a message asking you whether you want to edit the data source or edit the main document. Choose the Edit Data Source button to type the information that varies in each version. The Data form dialog box appears. Type the information you want in each data field box and then press ENTER. To move to the next or previous data field box, press TAB or SHIFT+TAB. Continue typing information, choosing the Add New button to start each new record. Choose the OK button in the last. Opening a Data Source To open an existing data source, Select Open Data Source from the Get Data drop-down list. The Open Data Source dialog box that appears works just like the File Open dialog box. Select the document you want to use and click OK. Word will open the document and table you back to the Mail Merge Helper dialog box. Step 3: One you've completed the second step-Creating a new data source or Opening an existing data source-you can complete the main document by inserting merge fields and by typing or adding information of your letter as given in Figure 30.

122


Word Processing

Figure 30: Creating a New Data Source

This can be done by: a)

Completing a form letter main document: Type or add any text and graphics you want to include in each letter. Then insert a merge field where you want each category of addressee information to be printed as shown in the Figure: 31. Place the insertion point in the document where you want to insert information from the data source, click the Insert Merge field button on the Mail Merge toolbar and then choose the appropriate merge field. Choose save from the file menu after editing the main document.

Figure 31 : Format of Main Document

123


Lab Manual - 1

b)

Merging the data source with the main document:

Before merging the main document with the data source, the following things should have been done: 1) All the addressee information in the data source should have been typed. 2) All the merge fields should have been inserted at the desired location into the main document. To merge a data source with the main document Click, the View Merged Data button on the Mail Merge toolbar while the main document is in the active window. Word displays information from the first data record in place of the merge fields in the main document text. To view information from other data records, click one of the arrow buttons on the Mail Merge toolbar, or type a record number in the Go To Record box.

Figure 32: Document After Mail Merged

124

Figure 33 : Logical Operations of Mail Merge


Lab Exercises 3 a) Find the word “ing” in your document, without using the whole word option. b) Find the “single space”(“ ”) in your document and replace it with “tab space”(“ ”). c) Create header and footer, where header must contain the name of the file and footer should have page number (right side) and your study center name on (left side). d) Insert an image in your document from some directory and resize it into 4inch width and 6-inch height. e) Create table of 10 rows and 5 columns in your document, give space between the lines and do shadow on the first row. f) Insert a following clip in your document and keep wrapping style “In line with text”

Word Processing

h) First type the following text in a word document and check the spelling and grammar in the following paragraph and change it with appropriate words. Anyone who has complted a grabuation from a affiliated university is suitable for IT field. IT field do not expect any specialijation from your graduation but it expect good problem solving, logical thinking and good communication skills. This can be achived along with your curiculum subjects by spending a hour per day. R.S. Agarwal is good subject oriented book to preparing aptitude. Any MBA entrance book are suitable to prepare logical reasoning etc. In fact anyone who is not technically strong but have logical thinking skills is very much suitable for this field. It do not mean that technical people are not suitible."

i) j)

Find the synonyms of Replace. Write a greeting letter for New Year, prepare a database of yours friends and relatives. Use the mail merge facility to generate customized multiple letters for them. k) Add the word Naveen in word dictionary so whenever users type it wrongly it shows red underline. l) Create Hyperlink of Word “IGNOU University” with website “ http://www.ignou.ac.in”.

125


Lab Manual - 1

3.7 SUMMARY In this unit, we have focused basically on formatting a text. We are sure that you can quickly produce professional looking documents and maintain consistent formatting now. Various formatting techniques including embellishing individual characters, changing the indentation of paragraphs, adjusting the white space between lines and paragraphs etc. have been explained in this unit. After going through this unit, you must have learnt various ways of editing text. You must have learnt how the use of find command facilitates the repeated occurrence of a word or text in the document. All the editing tools described in this unit help you develop and refine the content of your documents. When you use the Page Setup command on the file menu to specify a paper size, the options that are available depend upon the capabilities of the printer you selected. By the end of this unit, you must have also learnt the creation and usage of Cliparts, Images and Tables. You also learnt about the mail merge functions to generate multiple letters according to your database.

3.8 • • • • • •

126

REFERENCES/FURTHER READINGS

First Course in Computers by Sanjay Saxena, Vikas Publishing House Pvt Ltd Essential Ms Word 2000 by Marmel, BPB Publications. Fundamentals Of Computers And Information Technology by M N Doja, Deep & Deep Publications Ms Word 2000 An Introduction by M Lotia, BPB Publications. http://www.addbalance.com/word/wordwebresources.htm http://www.bcschools.net/staff/WordHelp.htm


Spreadsheet

4.0 SPREADSHEET Structure 4.0 4.1 4.2

Introduction Objectives Start Excel 4.2.1

4.3

4.4

4.6

4.7 4.8 4.9 4.10 4.11 4.12

Components of Excel Spreadsheet

Working with Excel 4.3.1

Selecting Cells

4.3.2

Enter and Edit Data

4.3.3

Data in Series

4.3.4

Data Correction

4.3.5

Cell References

4.3.6

Navigate Worksheet

4.3.7

Rearrange Cell Contents

4.3.8

Save and Protect Workbook

Page Set-up 4.4.1

4.5

Page Nos.

Getting Worksheet Printed

Formulas Basics 4.5.1

Basic Properties of Formulas

4.5.2

Operators in the Order of Precedence

4.5.3

How to Enter a Formula

4.5.4

Editing Formula

Functions 4.6.1

Arithmetic

4.6.2

Text – These functions are used to Manipulate Textual Data

4.6.3

Data and Time

4.6.4

Lookup and References

4.6.5

Logical – These Functions are used to Test the Conditions

Function Wizard Graphical Representation In Excel Chart Wizard Exit EXCEL Summary References/Further Readings

127 128 129 129 130 131 132 132 133 134 134 135 137 139 141 142 143 143 143 144 144 145 148 151 153 154 155 157 159 161 162 163

4.0 INTRODUCTION In unit three of this block, you have already explored one component of the well known office automation package, i.e., MS WORD, responsible for documentation management. Every office has numerical tasks to be performed, be it related to taxation, or salary or any other job, answer to such mathematical task is just another component called Microsoft Excel, an application software of the package Microsoft Office. Excel is a powerful spreadsheet tool, used by different people in their day-to-day jobs. You might be thinking What is Microsoft Excel? Microsoft Excel is a spreadsheet application.

127


Lab Manual - 1

Spreadsheets are brilliantly conceived ways to organize data by grouping it into rows and columns. It is used to organized, analyzed and manipulate all type of data but it provides enhanced functionalities for numerical data. In unit 3 of this block, you have already worked on MS Word thus you can easily identity that both packages have very similar menu, toolbars and icon, and hence it will help you to understand Excel GUI (Graphical User Interface) easily. In this lab, you will learn how to use Microsoft Excel to enter, analyze organized and manipulate data and prepare professional looking worksheets. You will learn the difference between a spreadsheet and a work book. You will also learn how to use the sort command and print a spreadsheet. MS-Excel is a Windows based application package that can be used to automate tasks such as calculation and analysis of data. MS-Excel, it works the way you want i.e. it can be customized. It provides ease of work with the following features:

• • • • • • • • •

Tip Wizard: Guides you to work more effectively while you work by displaying various helpful tips and techniques based on what you are doing. See-Through View: When you select cells with colored text, the color remains the same instead of appearing in an inverse color scheme. Euro currency symbol: Additional number formats are available with the euro currency symbol. Drag and Drop Feature: It helps you to reposition the data and text by simply dragging the data with the help of mouse. Autofill: It helps you to fill rows or columns with the series of data. Autosum: You can add a large range of data by simply selecting a tool button. Windows Interface: As Excel is Windows based package therefore the user interface is consistent. Shortcut Menus: Commands appropriate to the task that you are doing appear by clicking the right mouse button. Built-in Spell Check: You can maintain a dictionary of the words usually used in your work and spell-check your spreadsheet.

Before you start working on the worksheet, the knowledge of the concepts and movement on the workbook is necessary.

4.1 OBJECTIVES The objective of this unit is to help you understand the basic features of Excel such as the creation of worksheets and computation of data. After completing this unit you will be able to :

128

• • • • • •

Understand the screen display of Excel; Create a Workbook; Edit a Workbook; Save and protect workbook; Perform Calculations on data; Format the workbook & worksheet;


• • • • • •

Spreadsheet

Page and margin setup; Print a worksheet; Reform different functions on data; Footer/ Header setup; Work with Excel charts; and Use differ shortcut keys.

4.2 START EXCEL a)

Start Windows.

b)

Click on the Programs.

c)

In the Program Manager Window click on MS-Office icon.

d)

In the MS-Office window, click on MS-Excel icon as shown:

4.2.1

Components of Excel Spreadsheet

The Figure 1 below shows different components of MS-Excel workbook you will find that most of those components are similar to word. Menu Bar: Different options for selection. Standard Toolbar: It is displayed by default and provides shortcuts for the common commands used. Formula Bar: Any text, data or formula that is being keyed-in or edited is displayed in it. Name Box Displays the address of the current cell. Active Cell

Standard Toolbar Formula Bar

Name Box

Row Headings

Menu Bar

Sheet Tab

Status Bar

Column Headings

Scroll Bar

Figure 1: Different Components of Excel Spreadsheet

129


Lab Manual - 1

Scroll Bars Used to move up or down in the worksheet using mouse. Sheet Tab Displays the name of the current worksheet that can be changed by double clicking on it and giving a new name in the dialog (means dialogue) box. Status Bar Left part displays the various messages like Ready mode (when Excel is ready to accept data into the spreadsheet) or Edit mode (while in the editing mode). The right part highlights the status of keys of the keyboard. Row Headings They are numbered as 1, 2, 3 .... 16384. Column Headings These are addressed as A, B, C,....IV. Active Cell Intersection of each row and column is called a cell. Worksheets and Workbook MS-Excel document is called as a Workbook. Each Workbook contains 16 worksheets by default. This number can be changed if required by resetting the default options. Worksheets within Workbooks make it easy to bind files of related information. When a Workbook is opened, all worksheets of that workbook become available to the user automatically.

4.3 WORKING WITH EXCEL Firstly, open the workbook to start your work on a worksheet. At times, you might require to insert or delete a worksheet, and cells to be selected. Create a Workbook Select the New.. command from the File menu. The Workbook is opened by the default 130

name of BOOK1.


Spreadsheet

Open a Workbook To open an existing Workbook, select Open option from the File menu. Names of the recently used files are listed in the File menu and can be selected by merely clicking on the name of the file to be opened. Find a Workbook Choose File Open command. Select Find File.. option from the Dialog box that is opened. Consequently, another Dialog box is opened in which the details like file name, directory are to be given.

Insert a Worksheet To insert a Worksheet between two worksheets choose Worksheet option from the Insert menu.

Delete a Worksheet To remove a worksheet from the workbook, select Delete Sheet from the Edit menu. A Dialog box will appear to confirm this action. Move the Worksheet To move the worksheet in the same workbook, place the mouse pointer on the sheet tab, press the left mouse button and drag it to the desired position. Release the button.

4.3.1

Selecting Cells

You can select a single cell or a group of cells using mouse or keyboard. Using Mouse Click on the cell with the left mouse button. That cell gets selected and becomes the active cell. Whatever you type goes into this cell. To select a range of cells, click on one cell, hold down the left mouse button and drag the mouse pointer to the last cell of the range you want to select. Using Keyboard There is shortcut keys as given in Table 1, you can use for speed up your work or to avoid use of mouse. Table 1: Shortcut Keys For Selecting Areas in Excels. To Select

Press

Current Cell

Enter

Entire Column

Ctrl + Spacebar

Entire Row

Shift + Spacebar

Entire Worksheet

Ctrl + Shift + Spacebar

Extend Selection to End of Data Block

End, Shift + Arrow key 131


Lab Manual - 1

4.3.2

Enter and Edit Data

The various kinds of entries that can be made in a cell are: Text First select the cell in which the data has to be entered and type-in the text. Press ENTER key to finish your entry. The data will be displayed in the active cell as well as in the formula bar. To enter digits as text (calculations cannot be done using these kind of entries) use an apostrophe (') as the first character.

Number Numbers include digits from 0 to 9 and some special characters like $ % + - / ( ) , . E e Date and Time Date and Time entries are interpreted in a special way in Excel. They are represented as numbers for Excel given to each day from 01:01:1900 (serial number 1) to 31:12:2078 (serial number 65380). Although when you type a date in the cell like 01/01/97, it will be displayed as it is. Example: Type TODAY () in a blank cell and press ENTER key. (This function will display the system date and time)

4.3.3

Data in Series

You can fill a range of cells either with the same value or with the series of values. This can be done using Auto fill handle (small square on the bottom-right corner of the active cell) Fill Handle

Fill Handle

132

Figure 2 : Fill Handle in Spreadsheet or Work sheet


Drag this handle till the last cell to create a range of cells which are to be filled-in with the values.

Spreadsheet

Example: Enter MONDAY in cell E20. Drag the Auto fill handle till the cell K20. (The whole range will be filled with days from MONDAY to SUNDAY.) To create a series of numbers

Figure 3: For Creating Series Dialog Box Example: Select the cell H20 and Enter 1 in it. Select the range from H20 to H11. Though Excel provides the facility of built-in lists (e.g. MONDAY to SUNDAY) to perform Auto fill, the users can also create their own custom lists which are used frequently in your worksheets as shown in Figure 3.

4.3.4

Data Correction

Data, if written incorrectly, can be edited by following ways: Select the cell with some value to be edited. Press F2 and using Backspace key erase the previous entry. You can retype the correct data. or Simply select the cell and retype the entry. To bring back the previous entry either click on Undo button on Standard Toolbar or choose Edit -> Undo option. or Pressing Alt + Backspace or ctrl-Z keys can also be used to perform the undo task. or To clear the cell entry, select the cell to be cleared and press Delete key.

133


Lab Manual - 1

4.3.5

Cell References

There are 16384 rows and 256 columns in one worksheet. The first cell is labeled as A1 (column as A and row number as 1) or R1C1. Example: R3C3 refers to row 3 column 3 and is equivalent to C3. Thus he last cell is labeled as IV16384. This is called the cell address and they reused to identify the cell. Cell references are given in different ways: Relative This refers to the cell relative to the given position. Example: Enter the following values: In cell A3 enter the value 34 In cell A4 enter the value 23 In cell A5 enter the value 89 In cell A6 enter the formula = A3 + A4 + A5 Copy this formula to the cell A7, and see the result. Observe the formula entered in cell A7. It is A4 + A5 + A6. The formula entered in cell A6 means the sum of the values given in the three cell given above the current cell. Therefore when we move down, the relation specified in the formula was copied (i.e. the three values given above the current cell which is A7 now). Absolute This refers to the specific cell irrespective of the position of the formula. The '$' sign is used to denote an absolute reference. Example: In the cell B3 copy the formula $A$3 + $A$4 + $A$5 Copy this formula to the cell B4. We find that the result and the formula remains the same. Mixed It is a combination of both relative and mixed references. It has one absolute co-ordinate and one relative co-ordinate. $D1 and D$1 are both examples of mixed references.

4.3.6

Navigate Worksheet

With Mouse You can move the mouse pointer to move to any cell of any worksheet of the workbook. This is done through:

134

Click on up-arrow or down-arrow button on the scroll bar.


Spreadsheet

Click on the sheet tabs. Click on any cell. To move quickly to any cell Choose Edit -> Goto. With keyboard Table 2: Shortcuts for Navigating Worksheet TO MOVE

KEY PRESSED

Right, Left, Up, Down one cell

Arrow Keys

Up or Down one screen

PgUp or PgDown

Beginning of row

Home key

To cell A1

Ctrl+Home

To lower right corner

Ctrl+End

To last cell in current row

End or Enter key

To lower right corner of window

End (with Scroll Lock on)

To upper left corner of window

Home (with Scroll Lock on)

Search and Replace Data To look for the data which is entered by the user, choose Edit -> Find. Data to find

Figure 4 : Dialog Box for Find and Replace in Excel Sheet To replace the data, click on Replace... button in the dialog Box given in Figure 4. or Choose Edit -> Replace.

4.3.7

Rearrange Cell Contents

Rearranging cell contents includes moving or copying or clearing cell contents. This also involves inserting or deleting rows or columns. This can be done either by cut and paste method or drag and drop method.

135


Lab Manual - 1

Move or Copy Cell Contents Drag and Drop method Select the range of cells which are to be moved. Point to the border of range. The mouse pointer will change its shape to an arrow. To move, press the left mouse button, drag it to the new location and release the mouse button. To copy, press the Ctrl key while dragging the contents. Short-cut menu Press the right mouse button while dragging and dropping cell contents. From the short-cut menu, choose Move to move the contents, or choose Copy to copy the contents. Cut and Paste Method Select the cell range. Select Edit -> Cut (to move the range of cells) or Select Edit -> Copy (to copy the range of cells) Select the upper left corner of the new location where you want to place the cell contents. Choose Paste option from Edit menu. Inserting or Deleting Rows and Columns Many a times you may require to add a row of data or a column of data which you forgot to enter earlier. Excel provides you the facility to insert rows or columns into the existing worksheet very easily. One thing which has to be taken care of is that inserting a row of data will shift the rest of the rows down and cause the last row of the worksheet to be removed. Same is the case while we insert a column in the worksheet, the rest of the columns shift right. This happens because the total number of rows and columns remain the same. If there is any data in the last row or column of the worksheet that will be lost. To insert cells, rows or columns Select the cell(s) where you want to insert the cell(s), row or column. From the Insert menu, Choose Entire Column to insert the column Choose Entire Row to insert the row Choose Shift Cells Right or Shift Cells Down to insert the cell(s).

136


4.3.8

Save and Protect Workbook

Spreadsheet

After you finish up your work with the workbook you will require it to be saved so that it can be opened later to resume the work in it. To give the name and save the workbook Choose File -> Save As command To simply save the workbook Choose File -> Save command or Click on the Save File Tool button

To protect the Workbook Your data can be very confidential which has to be saved from unauthorized people. Click on Options... button from the File -> Save As Dialog box. You can restrict the access of that workbook from other users in 3 different ways: Protection Password Type the password which will be required to open the workbook in the Protect Sheet dialog Box as given in Figure 5. The password can be up to 15 characters long, can include alphabets (upper case or lower case), numbers and special characters. It is case sensitive also. You will be asked to re-enter the same password. Click on OK.

Figure 5 : Dialog Box for Protecting the WorkSheet

137


Lab Manual - 1

Write Reservation Password This password will be required when you make changes in the existing workbook and then try to save that workbook. This prevents the unauthorized users to make any modifications in the workbook. The rules to give the password are same as Protection Password. Read-only Recommended If this option is checked, the following Dialog box as given in Figure 6 will be displayed every time you try to open the workbook.

Figure 6 : Dialog Box for Read Only Recondition

This option is checked if you want to discourage the other users from making any changes by mistake or you want to prevent the changes to be made by more than one users simultaneously (this is possible when more than one users are working on the same workbook). Other Protection Options You can apply protection to workbook elements and you can protect a workbook file from viewing and changes as given in Figure 7. If a workbook is shared you can protect it from being returned to exclusive use and prevent the change history from being deleted as shown in Figure 8 .

Figure 7: Protect Workbook Dialog Box

138


Spreadsheet

Figure 8: Protect Shared Workbook Option

4.4 PAGE SET-UP As with other Windows programs, Excel also provides you with the feature of WYSIWYG (what you see is what you get). Therefore it is always better to start with the page layout which you want as a printer copy also. For this: Open the File menu by clicking on the File. Click on the Page Set-up. The Figure 9 Dialog box is displayed.

Figure 9 : Page Setup Dialog Box

The Page option allows you to set the paper size, orientation of the data, scaling of the area etc. Excel inserts automatic page-breaks also. The Margins tab, when clicked, displays the Dialog box (Figure 10). You can set the top, bottom, left and right margins of the page. These are the distances in inches from the edge of the page. This also allows you to see the preview of the data when it will be printed. 139


Lab Manual - 1

Header/Footer tab gives (Figure 11) you the option to set the header (which will be displayed on top of every page) and the footer (which will be displayed at the bottom of every page). The header may include the name of the organization or date or any other thing you wish to write. The footer may include the page number or a line or something you wish to write. To add more data as header or footer, click on Custom Header or Custom Footer...

Figure 10 : Margin Setup Dialog Box

The Sheet tab has the option to select the area to be printed (i.e. the range of cells), set the row or column titles (these will be printed on every page), or select the page order from the multiple worksheets etc as shown in Figure 12.

Figure 11 : Header Footer Setup

140

Figure 12 : Excel Worksheet Setup


4.4.1

Spreadsheet

Getting Worksheet Printed

Information can be easily carted and looked into on the screens but it is difficult to share it with other people unless you have the hard copy of the same. To Print Your Worksheet Select the range of the worksheet to be printed. You can see the preview of the hard copy you will get.

Figure 13 : Print Options Dialog Box

Check if the printer is on-line and Choose File -> Print command. Select the appropriate options in the Dialog box which is displayed (Figure 13). Click on OK. Lab Exercises 1 (a) Add the values in cells A2 + A5 + C4 + D2. Assume any Numerical Values in these cells. (b) Replace the value 345 given in your worksheet to ‘435’. Use rule & replace tool. (c) Rearrange your cells contents in column A (Name) in, Alphabetical Order. (d) Save & Protect workbook with password ‘XYZ’ give only Read only permission to other users. (e) Take the Printout of a selected area of your worksheet. (f) Take the print of 4 different tables in a worksheet, in the Page Order of then down”.

“Across,

(g) Create the following balance sheet for loan of 10,000, at the rate of 10% annual in 10 installments in your Excel Sheet. 141


Lab Manual - 1

4.5 FORMULAS BASICS Analyzing data and manipulating text are important features in any spreadsheet. Excel also provides these facilities using functions for different categories of tasks, like manipulation of text, date and time, calculation of numbers, date and time. Users might require to calculate percentage, average, interest. They want to look for a look for specific item in the large volume of data. All these tasks can be easily done either by typing in the functions based formulas or by using function wizards. The concept of cell references will be extensively used. Formulas are widely used in simple (like addition, subtraction, multiplication and division) and advanced computing. They provide the power to analyze data extensively. Spreadsheets also provide an important feature of auto-recalculation every time a change is made in the cells. Any change made in one cell causes a ripple effect in all the dependent cells. There are basically two kinds of recalculations: Automatic This is the default mode in which the change in the value of the cell causes the recalculation of the whole worksheet automatically. Manual On selecting this option, the recalculation of the complete worksheet is done only on pressing F9 key. This option can be selected by choosing Tools->Option and then click 142

on Calculation tab.


4.5.1

Spreadsheet

Basic Properties of Formulas

A formula may consist of operators, cell references, range names, values and functions. A formula always start with an equal to (=) sign. When a formula is entered in the cell, after the Enter key is pressed, only the calculated result is displayed in the cell and not the formula. If we make a cell, containing formula, as an active cell, though it still shows the value, but in the formula bar, the formula is displayed.

4.5.2

Operators in the Order of Precedence

Operators indicate the type of calculation that you want to perform on the elements of a formula. There is a default order in which calculations occur. You can use parentheses in your formulas to control the order in which the calculations occur. Table 3: Operators Process

4.5.3

Operator

Description

Example

:

Range

B2:B5

Space

Intersection of Cells

-

Negation (single operand)

=-10

%

Percentage

=25%

^

Exponential

=10^2

* /

Multiplication (whichever) Division (comes first)

=5*3 =24/3

+ -

Addition (whichever) Subtraction (comes first)

=55+80 =40-25

&

Joining Text

=“work”&“book”

= < > <= >= <>

Equal to Less than Greater than Less than or Equal to Greater than or Equal to Not equal to

=A1=5 =B3< 1000 =B3>1000 =B3<=1000 =A5>=250 =A5<>100

How to Enter a Formula

To learn to enter the formulas, first enter the data as shown below in worksheet :

143


Lab Manual - 1

(a)

In the cell D5, enter the formula as: =(40%)*C5

(b)

Copy this formula in cells D6 to D9.

(c)

In the cell E5, enter the formula as: =(20%)*C5

(d)

Copy this formula in cells E6 to E9.

(e)

In the cell F5, enter the formula as: =C5+D5+E5

(f)

Copy this formula in cells F6 to F9.

Formulas can be entered by referring to the values of other worksheets of the workbook, or by referring to the values stored in other workbook. Example: By referring to other worksheet cell =Sheet2!B3 + A2 (Sheet2!B3 refers to the value stored in the cell B3 of Sheet2 while you are working in Sheet1.) By referring to the cell of other workbook = 100 ([Employee.xls] Sheet1!$D$2) (In the formula given above, [Employee.xls]Sheet1!$D$2 refers to the cell D2 of Sheet1 of workbook Employee.xls.) This also creates a link between worksheets and workbooks. Therefore, while making changes in these linked worksheets and workbooks one has to be careful, as the change will affect the dependent and linked cells also.

4.5.4

Editing Formula

The formulas can be edited in the similar way as you have been editing text or number entries. You can edit the formula by pressing F2 key, and make changes directly in the cell. Type the changes in the formula bar. Double-click on the cell containing the cell and make changes as the formula is displayed in the cell.

4.6 FUNCTIONS The built-in formulas are called functions. The users have to provide the cell references or addresses only. Theses are called arguments of the function that are given between a pair of parenthesis like ( ). The functions perform the operation on the given values and return the result that is displayed in the same cell where the function was entered. The use of functions also shortens the formula. Example: Suppose you want to add the values of cells C10 through C20. You can enter the formula as = C10 + C11 + C12 + C13 + C14 + C15 + C16 + C17 + C18 + C19 + C20. 144


You can get the same result if you use the function instead, like = SUM (C10:C20) Complex formulas can be created using functions. Some of the tasks can be accomplished through functions only.

Spreadsheet

Example: To display the current date and time, you have to use TODAY () or NOW () functions. Categories of Functions Excel provides you with the various categories of functions that are as below:

4.6.1

Arithmetic

These functions are used for simple mathematical calculations of number data. Some of these functions are given below: SUM (num1, num2, ...) Returns the sum of all the numbers in the list of arguments. Example:

= SUM (A3, G3) = SUM (B5:K5)

SUMIF (range, criteria, sum_range) Adds the cells specified by a given criteria. Range - is the range of cells you want evaluated. Criteria - is the criteria in the form of a number, expression, or text that defines which cells will be added. Example: = SUMIF (A1:A4,">100",B1:B4) ABS (number) Returns the absolute value of a number. The absolute value of a number is the number without its sign. Number - is the real number of which you want the absolute value. Example: = ABS (-162) = ABS (D7) EVEN (number) Returns number rounded up to the nearest even integer. Regard less of the sign of number; a value is rounded up when adjusted away from zero. If number is an even integer, no rounding occurs.

145


Lab Manual - 1

Number - is the value to round. Example: = EVEN (5.5) = EVEN (5) = EVEN (6) = EVEN (-15) EXP (number) Returns erased to the power of number. The constant e equals 2.71828182845904, the base of the natural logarithm. Number - is the exponent applied to the base e. Example: = EXP (3) INT (number) Rounds a number down to the nearest integer. Number - is the real number you want to round down to an integer. Example: =INT (6.2) =INT (6.2) FACT (number) Returns the factorial of a number.

.

Number - is the non-negative number you want the factorial of. If number is not an integer, it is truncated. Example: = FACT (5) MOD (number, divisor) Returns the remainder after number is divided by divisor. The result has the same sign as divisor. Number - is the number for which you want to find the remainder. Divisor - is the number by which you want to divide number. Example: = MOD (15, 2) = MOD (15, -2) PRODUCT (number 1, number 2, ...) 146

Multiplies all the numbers given as arguments and returns the product.


Number 1, Number 2,... - are 1 to 30 numbers that you want to multiply.

Spreadsheet

Example: = PRODUCT (B5:F5) ROUND (number, num_digits) Rounds a number to a specified number of digits. Number - is the number you want to round. Num_digits - specifies the number of digits to which you want to round number. Example: =ROUND (96.54,0) SQRT (number) Returns a positive square root. Number - is the number for which you want the square root. If number is negative, SQRT returns the #NUM! error value. Example: = SQRT (100) CEILING (number, significance) Returns number rounded up to the nearest multiple of significance. Number - is the value you want to round. Significance - is the multiple to which you want to round. Example: = CEILING (97.8,1) RAND ( ) Returns an evenly distributed random number greater than or equal to 0 and less than 1. A new random number is returned every time the worksheet is calculated. If you want to use RAND to generate a random number but don't want the numbers to change every time the cell is calculated, you can enter = RAND () in the formula bar and press F9 to change the formula to a random number. Example: To generate a random number greater than or equal to 0 but less than 100: =RAND ()*100 LOG (number, base) Returns the logarithm of a number to the base you specify. Number - is the positive real number for which you want the logarithm. Base - is the base of the logarithm. If base is omitted, it is as-summed to be 10. Example: = LOG (16, 2) 147


Lab Manual - 1

4.6.2

Text - These functions are used to Manipulate Textual Data

CONCATENATE (text 1, text 2, ...) Joins several text items into one text item. The "&" operator can be used instead of CONCATENATE to join text items. Text 1, text 2,... - are 1 to 30 text items to be joined into a single text item. The text items can be text strings, numbers, or single-cell references. Example: = CONCATENATE (“Soft”, “ware”) EXACT (text1, text2) Compares two text strings and returns TRUE if they are exactly the same, otherwise FALSE. It is case-sensitive but ignores formatting differences. Text 1 - is the first text string. Text 2 - is the second text string. Example: = EXACT (“poor”, “pour”) FIND (find_text, within_text, start_num) Finds one string of text within another string of text and returns the number of the character at which find_text first occurs. Find_text - is the text you want to find. Within_text - is the text containing the text you want to find. Start_num - specifies the character at which to start the search. If you do not specify the start_num, it is taken as 1 - the first character of within_text. Example: = FIND (“&”, “Jack & Jill”) LEFT (text, num_chars) Returns the first (or leftmost) character or characters in a text string. Text - is the text string containing the characters you want to extract. Num_chars - specifies how many characters you want LEFT to return. Num_chars must be greater than or equal to zero. Example: =LEFT (“Salesman”, 5) 148


RIGHT (text, num_chars)

Spreadsheet

Returns the last (or rightmost) character or characters in a text string. Text - is the text string containing the characters you want to extract. Num_chars - specifies how many characters you want to extract.

Example: = RIGHT (“Salesman”, 3) LEN (text) Returns the number of characters in a text string. Text - is the text whose length you want to find. Spaces count as characters. Example: = LEN (“ABRACADABRA”) LOWER (text) Converts all uppercase letters in a text string to lowercase. Text - is the text you want to convert to lowercase. LOWER does not change characters in text that are not letters. Example: = LOWER (“Limit”) UPPER (text) Converts text to uppercase. Text - is the text you want converted to uppercase. Text can be a reference or text string. Example: = UPPER (“limit”) MID (text, start_num, num_chars) Returns a specific number of characters from a text string, starting at the position you specify. Text - is the text string containing the characters you want to extract. Start_num - is the position of the first character you want to extract in text. The first character in text has start_num 1, and so on. Num_chars - specifies how many characters to return from text. Example: = MID (“Microwave”, 3, 4)

149


Lab Manual - 1

PROPER (text) Capitalizes the first letter in text and any other letters in text that follow any character other than a letter. It converts all other letters to lowercase. Text - is text enclosed in quotation marks, a formula that returns text, or a reference to a cell containing the text you want to partially capitalize. Example: = PROPER (“the high QUALITY”) REPLACE (old_text, start_num, num_chars, new_text) Replaces part of a text string with a different text string. Old_text - is text in which you want to replace some characters. Start_num - is the position of the character in old_text that you want to replace with new_text. Num_chars - is the number of characters in old_text that you want to replace with new_text. New_text - is the text that will replace characters in old_text. Example: = REPLACE (“Near”, 1, 1, “P”) SEARCH (find_text, within_text, start_num) Returns the number of the character at which a specific character or text string is first found, reading from left to right. It is not case - sensitive. Find_text - is the text you want to find. Within_text - is the text in which you want to search for find_text. Start_num - is the character number in within_text, counting from the left, at which you want to start searching. Example: = SEARCH (“L”, “Quality”) TRIM (text) Removes all spaces from text except for single spaces between words. Text - is the text from which you want spaces removed. Example: TRIM (" First Quarter

Earnings ")

SUBSTITUTE (text, old_text, new_text, instance_num) Substitutes new_text for old_text in a text string. 150


Text - is the text or the reference to a cell containing text for which you want to substitute characters. Old_text - is the text you want to replace.

Spreadsheet

New_text - is the text you want to replace old_text with. Instance_num - specifies which occurrence of old_text you want to replace with new_text. Example: = SUBSTITUTE (“Sale Price”, “Sale”, “Cost”)

4.6.3

Date and Time

Excel stores Date and Time as serial numbers. Though the values are displayed in the appropriate format which is recognized by the user. The functions to manipulate date and time are: DATE (year, month, day) Returns the serial number of a particular date. Year - is a number from 1900 to 2078 in Microsoft Excel for Windows Month - is a number representing the month of the year. Day - is a number representing the day of the month. Example: = DATE (97, 2, 12) DATEVALUE (date_text) Returns the serial number of the date represented by date_text. Date_text - is text that returns a date in a Microsoft Excel date format. Example: = DATEVALUE (“22-AUG-99”) DAY (serial_number) Returns the day of the month corresponding to serial_number. The day is given as an integer ranging from 1 to 31. Serial_number - is the date-time code used by Microsoft Excel for date and time calculations. Example: = DAY (“16-JAN”)

151


Lab Manual - 1

MONTH (serial_number) Returns the month corresponding to serial_number. The month is given as an integer, ranging from 1 (January) to 12 (December). Serial_number - is the date-time code used by Microsoft Excel for date and time calculations. Example: = MONTH (“6-MAY”) YEAR (serial_number) Returns the year corresponding to serial_number. The year is given as an integer in the range 1900-2078. Serial_number - is the date-time code used by Microsoft Excel for date and time calculations. Example: = YEAR (“7/5/96”) WEEKDAY (serial_number, return_type) Returns the day of the week corresponding to serial_number. The day is given as an integer, ranging from 1 (Sunday) to 7 (Saturday). Serial_number - is the date-time code used by Microsoft Excel for date and time calculations. Return_type - is a number that determines the type of return value. Example: = WEEKDAY (“2/12/97”) HOUR (serial_number) Returns the hour corresponding to serial_number. The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.). Serial_number - is the date-time code used by Microsoft Excel for date and time calculations. Example: = HOUR (“3:35 PM”) MINUTE (serial_number) Returns the minute corresponding to serial_number. The minute is given as an integer, ranging from 0 to 59. Serial_number - is the date-time code used by Microsoft Excel for date and time calculations.

152

Example: = MINUTE (“3:35 PM”)


NOW ( )

Spreadsheet

Returns the serial number of the current date and time. Example: = NOW ( ) TODAY( ) Returns the serial number of the current date. Example: = TODAY ( )

4.6.4

Lookup and References

These functions are used to search for the values in a table. HLOOKUP (lookup_value, lookupref, columnno, nearest) Searches the top row of an array for a particular value, and returns the value in the indicated cell. Use this function when your comparison values are located in a row across the top of a table of data and you want to look down a specified number of rows. Lookup_value - is the value to be found in the first row of the table. Lookup ref - is a table of information in which data is looked up. Columnno - is the row number in table_array from which the matching value should be returned. Nearest - Is a logical value that specifies whether you want HLOOKUP to find an exact match or an approximate match. If FALSE, HLOOKUP will find an exact match. Example: = HLOOKUP (“BASIC�, C4:E9, 6, FALSE) V LOOKUP (lookup_value, lookupref, columnno, nearest) Searches the leftmost column of an array for a particular value, and return the value in the cell indicated. Use this function when the comparison values are located in a column to the left or right of the data you want to find. Lookup_value - is the value to be found in the first column of the table. lookupref - is the table of information in which data is looked up. Columnno - is the column number in table from which the matching value should be returned. Nearest - is a logical value that specifies whether you want LOOKUP to find an exact match or an approximate match.

153


Lab Manual - 1

Example: = VLOOKUP (“KIM”, A4:B9, 2, FALSE)

4.6.5

Logical - These Functions are used to Test the Conditions

They return the logical value as TRUE or FALSE. AND (logical 1, logical 2, ...) Returns TRUE if all its arguments are TRUE; returns FALSE if one or more arguments are FALSE. Logical 1, logical 2,... - are 1 to 30 conditions you want to test that can be either TRUE or FALSE. Example: = AND (14>12, 4=4) OR (logical 1, logical 2, ...) Returns TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE. Logical 1, logical 2,... - are 1 to 30 conditions you want to test that can be either TRUE or FALSE. Example: = OR (2<8, 5>3, 6=2) NOT (logical) Reverses the value of its argument. Use NOT when you want to make sure a value is not equal to one particular value. Logical - is a value or expression that can be evaluated to TRUE or FALSE. If logical is FALSE, NOT returns TRUE; if logical is TRUE, NOT returns FALSE. Example: = NOT (5>3) IF (logical_test, value_if_true, value_if_false)

154

Returns one value if logical_test evaluates to TRUE and another value if it evaluates to FALSE. Up to seven IF functions can be nested


Logical_test - is any value or expression that can be evaluated to TRUE or FALSE.

Spreadsheet

Value_if_true - is the value that is returned if logical_test is TRUE. Value_if_false - is the value that is returned if logical_test is FALSE. Example: = IF (35>20, 35, 0) FALSE ( ) Returns the logical value FALSE. Example: = FALSE ( ) TRUE ( ) Returns the logical value TRUE. Example: = TRUE ( ) Lab Exercises 2 (a) Calculate the Simple Interest, Assuming any principle amount, rate of interest and time. (b) With different values of A and B, Prove the following formula in excel sheet. A^2-B^2 = (A+B) (A-B) (c) Assume, temperature is given in degree Celsius in a column. Use proper formula to convert the corresponding temperature into degree Fahrenheit. (d) According to the rule of XYZ shipping Company, the age of any employee should be between eighteen and thirty five years. Whenever any candidate gives invalid age (other than mentioned), proper comment should be flashed in the excel sheet. Create this in excel. (e) Use GOAL SEEK function calculate the value of the missing number ‘_’ in the given equation. 5*__ = 625.

4.7 FUNCTION WIZARD Excel also provides you with its built-in functions through Function Wizard. This guides you through all the steps of writing a function and its arguments. The results and examples are shown as you work on it. To use Function Wizard follow the given steps: Enter the given data.

Activate the cell D2.

155


Lab Manual - 1

Open the Function Wizard in either of the following ways – Click on the Function Wizard Tool on Standard Toolbar

or Choose Insert -> Function command or Press Shift + F3 A Paste Function Dialog Box will appear as shown in Figure 14. Click on Math & Trig in Function Category. Scroll down to choose Product from the list of Function Name. (Observe that the formula is shown in the Formula Bar)

Figure 14: Paste Function Dialog Box in Function Wizard Click on Next button. Click on cell B2 while Click on Next button. Click on cell B2 while the cursor is in number1 box. Go to number2 box and click on cell C2.

156


Spreadsheet

Figure 15: Dialog Box for Entry Selecting Values Infunction Click on Finish. (The result is shown in the cell D2) Copy this formula to cells D3 to D6.

4.8 GRAPHICAL REPRESENATATION IN EXCEL Charts are the graphic component of Excel. The data which is entered as tables can be viewed in the graphical form as charts which makes the figures of data effective, interesting, easy to understand, and easy to analyse and compare data. Chart can be of two types: MS-Excel offers different chart types, each of which has at least one subtype, or variation. You can change the chart type to present your data most clearly and effectively. Some of the popularly used charts are given below: Bar Chart - It consists of the series of horizontal bars that allow comparison of the relative size of two or more items, as shown in Figure 15. A bar chart illustrates comparisons among individual items.

157


Lab Manual - 1

Figure 15: Bar Charts

Column Chart - This consists of a series of vertical columns that allow comparison of the relative size of two or more items, as shown in Figure 16. A column chart shows data changes over a period of time or illustrates comparisons among items.

Figure 16: Column Charts

Line Chart – As given in Figure 17 below is a line chart shows trends in data at equal intervals. Each of the data series are plotted as lines of different colour and shading.

Figure 17: Line Charts

158

Pie Chart – In Figure 18 Pie charts are shown. It always shows only one data series and is useful when you want to emphasize a significant element in the data. These are the best charts to compare the percentages of the sum the data series. It represents only one data series.


Spreadsheet

Figure 18: Pie Charts

4.9 CHART WIZARD The Chart Wizard is a series of dialog boxes that guides you through the steps required to create a new embedded chart or modify settings for an existing embedded chart. It displays either five steps or two steps, depending on what is selected. If worksheet data is selected, all five steps are displayed because you're creating a new chart. If you've selected an existing chart to modify it, only two steps are displayed. When you choose the Finish button in any of the steps, the ChartWizard finishes your chart for you. Following are the steps to create the chart through Chart Wizard: 1)

To learn how to create a chart, you can use the data given in above example.

2)

Select the cells A1 to C6 and Click on Chart Wizard tool button from formatting Toolbar. OR use Insert chart.

Figure 19: Standards Charts in Chart Wizard

159


Lab Manual - 1

3)

Select the chart type from the charts displayed in the Figure 19. You can use press and hold button to see the preview which can help you in selecting the type of chart you want is fit with your data or not. And clicks on Next, Figure 20 will appear.

Figure 20: View Sample Chart in Chart Wizard

4)

As Shown in Figure 21, enter or check the data range and series of data in the box and click on Next.

Figure 21: Data Range and Series of Charts

5)

160

Sample of the chart labels are shown in Figure 22. Alongwith this, you can specify X-axis Label and Legend text. Enter the Title for the chart, X-axis and Y-axis. Click on Next.

Figure 22: Creating Chart labels


Spreadsheet

6)

Select an option to place the chart as an object or as a new sheet as shown in Figure 23 and click Finish.

Figure 23: Option to Place the Chart

The chart which is created can be printed in the similar way as the worksheet is printed. To Print the Embedded Chart This can be printed either with the data by selecting the range of worksheet including the data and the chart, or without data also by : •

Select the chart.

Choose File -> Print.

To Print the Chart Sheet •

Choose File -> Page Set-up.

After selecting the appropriate options for chart size, page size, margins, header and footer, Click on Print... (Print Preview button allows the user to view the chart before taking the print out.)

4.10 EXIT EXCEL When your work is finished and it has been saved properly, to close the file and exit MSExcel, Choose File -> Close command. Choose File -> Exit. If you have not saved your work before closing the file, the Dialog box to save the worksheet is displayed. 161


Lab Manual - 1

Lab Exercises 3 1) Select and use a function to get the same result as = C10 * C11 * C12 * C13 * C14 * C15. 2) Assume in a column “NUMBER.” numbers between 10 to 10 are stored, you are asked to calculate their corresponding “sum of squares” in a column and “sum of qubes” in another column. 3) Assume you need to select any sixteen people in the list of 1000 persons to give them two bed rooms flat in Delhi. How you can select these people using random function of Excel so that the process of allotment of plots will be fair. 4) According to your company policy no one should apply for any post more than once in the six month. Assume you have an old database of applicants, you are asked to type new entries of applicant in your database if you write any entry, which is against your company policy, and then proper error message should flash on your screen. Help: Your database may contains Name, Post applied, Date of Application etc.. 5) One school conducts a 100 mark exam for its students and grades them as follows: Grade A+: Marks>85;Grade A: 85>Marks>75;Grade B: 75>Marks>60 Grade C: 60>Marks>50;Grade D: 50>Marks>40;Grade F: Marks<40 6) Write a formula code in excel to calculate the grades for students, using nested- if statement. Show the result of your code with help of sample marks values. 7) Find how many ‘c’ characters are present in the given text also calculate total numbers of characters in the text.

“I measure the progress of a community by the degree of progress which women have achieved.” - B. R. Ambedkar

4.11 SUMMARY Excel is a powerful spreadsheet application, which provides different functionalities for organizing, analysis and representing data. You learned few to stored data in worksheet of worksheet and cell in this unit. The main advantage of excel is its formulas and function, in this unit we learned how to work with different formulas and how to use different functions available in the Excel. In this unit, you learned. What is an Excel workbook and worksheet, and how to work in it. Data is entered in the cells and can be edited, if required. Names can be given to a single cell or a range of cells. You can move in the worksheet either with keyboard, mouse or menu. Data that has been entered can be searched and replaced. The contents of the cell can be copied and moved anywhere in the workbook. We also learned about different printing issues and page setup issues in this unit. To improve your processing speed on Excel we have provided you different short cut keys.

162


4.12 REFERENCES/FURTHER READINGS •

Teach Yourself Ms Excel 2000 In 24 Hours by Reisner, Techmedia Publication

Excel 2000: No Experienced Required by Gene Weisskopf, BPB Publication.

Excel 2000 For Windows by Langer, Pearson Education India

http://www.vtc.com/products/Microsoft-Excel-2000-tutorials.htm

http://www.fgcu.edu/support/office2000/Excel/

http://www.bcschools.net/staff/MicrosoftOffice.htm

http://www.usd.edu/trio/tut/excel/

Spreadsheet

163


PRESENTATION TOOL Structure 1.0

Introduction

Objectives

1.1

1.2

Introduction to PowerPoint 1.1.1

Start PowerPoint

1.1.2

Ways of Creating Presentation

1.1.3

Saving and Closing Presentation

Working with PowerPoint 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8

1.3

PowerPoint Components PowerPoint Views Create a Presentation Create a Title Slide Create Bulleted List slide Creating a Graph Creating Tables Open A Presentation

Customizing the Presentation

1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 Summary

Working with text Working with Graphic tools Group or Ungroup the objects Animation in Presentation Slide Show Print the Presentation

INTRODUCTION In this unit we will get introduced to some of the components of PowerPoint and learn how to work with these components of PowerPoint and customizing our slide show. PowerPoint is a complete presentation graphics package. It gives you everything you need to produce a professional-looking presentation like text handling, outlining, drawing, graphics, clip art, and so on. It also offers rich speaker support and aids to help you create truly effective presentations. PowerPoint makes you, the presenter, and an independent producer of your own high-quality presentations. To help you about consistency in design and color use PowerPoint functions are really good, if try them. If you think you are not very good in designing at this stage, just apply one of the PowerPoint templates to your presentation and choose from among the thousands


of colour schemes available. Whether you need quick overheads for a team briefing, slides for a sales meeting, or dazzling effects for an on-screen presentation, PowerPoint wizards, templates, and Auto Layouts help you get right to work; and a complete set of easy-to-use tools assures you have everything you need to get your point across and share information with others.

OBJECTIVES After going through this, unit, you will be able to • • • • • • • • • • • • • •

Start, save and exit the PowerPoint application know the different PowerPoint views use the toolbar and menus to create a presentation create a presentation, use the blank slide option to create a slide of your choice create graphs as your slide add a new slide change the layout of a slide add a text by use the text tool. change the fonts, size and colour of text. add drawing objects in your slide by select the drawing shape from the drawing toolbar. work with objects, group or ungroup objects Work with animation tools Know how to use different printing options

1.1 INTRODUCTION TO POWERPOINT Microsoft PowerPoint is one of the largest presentation software in the word. It is because of its excellent features to quickly prepare OHP presentations or slide shows. It has nice graphical supports, which are supplementary with speaker notes and its interoperability with other office software like word and excel.

1.1.1 Start PowerPoint You can start PowerPoint in the same way as you do other MS-Office applications. There are many different ways of starting PowerPoint 1.

To open the Microsoft PowerPoint application you can (a)

Double click on the Microsoft PowerPoint icon (as given below) on the desktop.


(b)

Open Microsoft PowerPoint from the Start menu (Start All Program Microsoft Office Microsoft PowerPoint as shown in the figure 1 or directly Microsoft PowerPoint).

Figure 1: Open Microsoft PowerPoint When Word opens, a blank document with name Document1 will appear similar to Figure 2. You will be prompted with four choices. Each of these options are explained in next section.


1.1.2 Ways of Creating Presentation You can create a new presentation in several ways. You can start by working with the AutoContent wizard, in which you begin with a presentation that contains suggested content and design. You can also start with an existing presentation and change it to suit your needs. Another way to start a presentation is by selecting a design template that determines the presentation's design but doesn't include content. You can also begin with an outline you import from another application or with a blank presentation that has neither suggested content nor design. If Power Point is already open or this box does not appear, select File New from the Menu bar.

1. AutoContent Wizard It is similar to the MS-Word Auto Wizard to create a Resume if you did that exercise this will be really very simple for you. The AutoContent Wizard provides templates and ideas for a variety of presentation types. Page through the wizard by clicking the Next button on the bottom of each page after making necessary choices. 2. Design Template Power Point provides many templates with different backgrounds and text formatting to begin your presentation. Preview each design by highlighting the template name on the list. Press OK after you have chosen the design. 3. Blank Presentation Select Blank Presentation to build the presentation from scratch with no preset graphics or formatting. 4. Auto Presentation Layout After selecting the presentation type, you will be prompted to choose the layout of the new slide. These layouts include bulleted lists, graphs, and/or images. Click on each thumbnail image and a description will be printed in the message box. Highlight the layout you want and click OK.


1.1.3 Saving and Closing Presentation To save a presentation on disk, click the Save button on the Standard toolbar. When you save a document for the first time, Word displays the Save As dialog box so that you can type a name for the document. Make a habit of saving your presentation after each slide, as PowerPoint may stop abruptly due to hardware or software problem. 1.1.1 How to save a document? 1. Select File Save from the menu bar. 2.

Select File Save As from the menu bar.

You must be interested to know that what is a difference between Save and Save As option? The main difference is that the Save option will simply overwrite your existing file, whereas Save As will give you the chance to choose any of the options/format given in its dialog box.

It is good practice to choose a filename with eight characters or less, as additional letters may not be visible.

2. Click the Save button on the standard toolbar. 3. Press CTRL+S on the keyboard. 1.1.2

How to close a Presentation?

When you finished working in PowerPoint close the active presentation and then quit PowerPoint by choosing Exit (Windows) from the file menu. To work on another Presentation in PowerPoint, close the active presentation by choosing Close from the file menu and then open the other presentation. Also, several presentations can be open at the same time. To work in a particular presentation, click anywhere in its presentation to make it active, or select the presentation name from the window menu. To close the current presentation by you can either select File Close or click the Close icon you can locate it on your standard toolbar. If you are prompted with a dialogue box asking, “Do you want to save the changes you made to presentation1.ppt?” It means you have not saved the file. Think always before Clicking on No.

Check Your Progress 1 Question 1: Create a Presentation using AutoContent Wizard. Where, you should select type of presentation as “Motivating A Team” and output to be use is “On screen presentation”. Question 2: Find out the difference between Save and Save As option? Question 3: How a new presentation can be created if already you are working with some other Presentation?

You can save your document in different format like Web Page, Text format, Rich Text format, Document templates using Save As option.


1.2 WORKING WITH POWERPOINT 1.2.1 PowerPoint Components From the PowerPoint window, you can create presentations and use its toolbars and menus. Window Control Buttons Standard Toolbar

Formatting Toolbar Scroll Bar

View Buttons Drawing Toolbar Status Bar

Title Bar located at the top of the screen, displays the name of the presentation. Menu Bar located below the title bar, lists the options. The Status Bar Messages appear at the bottom of the window in an area called the status bar. These messages describe what you are seeing and doing in the PowerPoint windows as you work. Normally, the status bar tells you which slide you're working on (Slide 1, Slide 2, and so on). When you choose a command, the status bar provides a short message telling you what that command will do. Three shortcut buttons appear on the right side of the status bar - New Slide, Layout, and Template. Clicking the New Slide button presents the New Slide dialog box and adds a slide to your presentation immediately following the current slide. Clicking the Layout button lets you change the layout of the current slide. Finally, clicking the Template button allows you to apply or change the template for your presentation.

Double Arrow Scroll Button


The Toolbars You can use toolbars for quick access to commonly used commands and tools. When you first start PowerPoint and open a presentation, the Standard and Formatting toolbars are displayed just below the menu bar, and the Drawing toolbar is displayed vertically on the left side of the window. Different toolbars appear automatically in each view. The Scroll Bar There's a vertical scroll bar on the right side of the PowerPoint window. The scroll bar has an elevator as well as double arrow buttons you can use to move from slide to slide. To move slide by slide using the double arrow buttons, You can quickly move one slide up or one slide down using the Previous Slide and Next Slide buttons icons below the vertical scroll bar. To go to the next slide, click the double down arrows and similarly for previous slide click the double up arrows. Table: Some Basic Key Shortcuts. Action Open a presentation New presentation Save As Save Print Help

Key Shortcuts CTRL+O CTRL+N F12 CTRL+S CTRL+P F1

1.2.2 PowerPoint Views Microsoft PowerPoint comes with different views to help you while you are creating a presentation. The two main views you use in PowerPoint are normal view and slide sorter view. To easily switch between views, you click the buttons at the lower left of the PowerPoint window. A PowerPoint presentation is a collection of your slides, handouts, speaker's notes, and your outline, all in one file. PowerPoint gives you the flexibility of switching between different views during the creation of slides for a presentation. •

Slides are the individual "pages" of your presentation. Soon, you'll be creating slides with PowerPoint. Slides can have titles, text, graphs, drawn objects, shapes, clip art, drawn art, and visual created with other applications and more.

Handouts support your presentation. You have the option of providing handouts for your audience. Handouts consist of smaller, printed versions of your slides.

Speaker's Notes can be created and printed. You'll see a small image of the slide on each notes page, along with any notes you type on the notes pages.

Outlines As you're working on a presentation, you have the option of working with your presentation in outline form. In the outline, your titles and main text appear, but not your art or the text typed with the Text tool.


Figure 1: Different views of Microsoft PowerPoint

1.2.3 Create A Presentation As we have discussed earlier, when you create a new presentation, you have choices about how to proceed. You can use the AutoContent wizard to help you organize what you want your presentation to say. You can use the Pick a Look wizard to help you apply a template and set up the masters. You can also start with a blank presentation if you want to use the default presentation - either the PowerPoint default or one that you set up. Remember in PowerPoint, your entire presentation is in one file everything is under an umbrella. That includes all the slides, the outline, the speaker's notes, and the handouts, as well as the formatting information you build into your presentation. Using a slide layout is an easy way to begin building a presentation. You choose a slide layout by selecting New Slide from the Insert menu and then selecting the layout you want in the New Slide dialog box. There is a variety of slide layouts, some with placeholders in which you type text, and some with placeholders set up to make it easy to add graphs, charts, clip art, or other objects.

1.2.4 Create A Title Slide A Title slide is the first slide that will be displayed in your presentation. A Title slide is divided into two parts - the top part for the title and the bottom part for the sub-title or the topic. To create a title slide follow the given steps: 1.

Select File New from the Menu bar, to display the presentation dialog box. Click the Blank Presentation, and than OK


2.

Select Title slide from the AutoLayout dialog box and click on OK

3.

It will display the blank title- slide to enter information.


4.

Type the title and sub-title.

1.2.5 Create Bulleted List slide Once you fished creating title slide, now onward you can follow the procedure to create a normal text slide (Bulleted List slide). 1. Select File New from the Menu bar, to display the presentation dialog box. Click the Blank Presentation, and than OK as previous. 2. Select Bulleted List slide from the AutoLayout dialog box and click on OK


3.

It will display the blank Bulleted List slide to enter information.

Add A New Slide PowerPoint presentation file is a collection of slides. Till now, you have created a slide. Now you want to expand the presentation to add more slides.

To add a new slide 1. 2. 3.

Select New Slide from the Insert menu to display AutoLayout dialog box. 0R Press Ctrl+M. Select the layout. Click on OK to display blank slide layout to enter information.

1.2.6 Creating Graph A graph can be created and viewed in different formats, as a pie, bar, column and so on. Legends, titles and data labels can be added to improve readability. To create graphs do the following steps: 1.

Select File New from the Menu bar, to display the presentation dialog box. Click Blank Presentation and press the button as shown in previous section

2.

You will see the different types of graphs under Choose an AutoLayout. You can select any one style of graph as per your choice. You will notice that the rectangle shown around the selected graph has darkened. This shows that the graph style you wanted has been selected.


3.

Click your mouse cursor on the OK sign. It will display the blank graph layout slide.

4.

Double click on the graph box marked as "Double click to add graph" to go in the graph mode. Now you can create and modify the graph. You will see some data also in the Presentation - Datasheet. Please do not get disturbed. This is only a default data. You can put the new data i.e. modify the existing data as per your datasheet by taking the mouse cursor and clicking it once.


5.

Whenever you change the values in the datasheet, it will change the graph automatically, displaying backside of the datasheet.

Change the graph type You can change the graph type as per your requirement. There are two common ways to change the graph type. One way is Click on graph. It will display you different types of graphs. You can choose any of them. The second way is, Select Chart Menu Chart Type from the menu to display chart type dialog box. From the chart type dialog box, you can select 2D or 3D type graphs and click on OK.


Change the 3-D view You can rotate the graph in the 3-D view. Select 3-D view from the Chart Menu 3D View to display a dialog box. The graph preview is display the graph in left to right side and top to bottom side. You can change them by click on rotate buttons. Click on left rotate button to view the graph in right to left side. Click on up arrow rotate button to view graph in bottom to top side.

Chart options To select different chart options like chart tiles, you select Chart Chart Option, and following dialog box will appears. Some of the components are discussed below:


Creating Titles: Sometimes you may want to include more than one graph on a single slide. In such cases, each individual graph will need to be identified. This can be done using titles. Select Titles from the Insert menu to display titles dialog box. Click on the check boxes in the dialog box, you can create titles in the graph. Data labels: Select Data Labels from the menu to display a dialog box. You can show the value or labels with the graph. Select any one and then click on OK. By default none is selected. Gridlines: Select Gridlines from the menu to display a dialog box. Click on check box to hide or display the gridlines and than click on OK.

1.2.7 Creating Tables Tables are used to display data in a columnar form. One or more rows of cells commonly used to display numbers and other items. for quick reference and analysis. Items in a table are organized into rows and columns. In a table, the intersection of a row and a column forms one cell, in which you can type text. If the text of your columns does not fit into your slide, you can reduce the column width. To create tables perform the following steps: 1.

Select File New from the Menu bar, to display the presentation dialog box. Click Blank Presentation and press the button as shown in previous section

2.

Select Table layout from the AutoLayout list and than click on OK to display a blank Table presentation slide. From where you can add table.

3.

Double click on Table box to display Insert table dialog box. Type number of columns and number of rows in respective boxes of your requirement and click on OK to go in word table( rows and columns) form.


4.

And lastly type your information in the cells.

1.2.8 Open A Presentation You can open a PowerPoint presentation which either you or some of your friend had created.

To open a presentation 1.

Select Open from the File menu to display the open dialog box. OR Press Control+O shortcut


2.

Select the directory from the directories list, which contain the presentation file.

3.

Select presentation file from the file name list box and than click on OK to open a presentation. OR

In the Standard toolbar, click button OR Click a shortcut on the Places Bar that contains the presentation you want. OR Tip To open a file you've used recently, click History on the Places Bar. You can also click the file name at the bottom of the File menu. If the list of recently used files isn't displayed, click Options on the Tools menu, click the General tab, and then select the Recently used file list check box.

Check Your Progress 2 Question 1: Create a Presentation about your favorite unit of CIT using Blank Presentation. Where, first slide should be title slide and other slides will be bulleted list slides. Question 2: Assume the student enrollment numbers of IGNOU MCA, BCA and CIT programmes for the years 2007, 2008 and 2009. Using this data create a Graph in your Presentation. Question 3: Use the graph of previous question number 2 and change it into 3D view with rotation of 25 and elevation 20. Show proper title and data labels. Question 4: Create a table of your friends showing their name, fathers name, age, Area of Interest and college/school name.


1.3 CUSTOMIZING THE PRESENTATION 1.3.1 Working With Text You can create a text object, edit text and move text object.

Create a text 1. 2.

Select Text Box from the toolbar. Leave the box on blank slide and type text on it.

3.

When finish typing the text, click anywhere of the blank slide.

Edit the text Click on the text object. While cursor is blinking on it, you can add more characters or using Del key / Backspace key to remove characters.

Move the text Click on text object to select it. Move the mouse cursor to border of the text object and click on it and hold down the mouse button. Move the text object any where of the slide and leave the mouse button.

Delete text •

Click on object to select. Press DEL key to delete.

Resize text •

Click on object to select. Move the mouse cursor to the corner of the object, when cursor changes its shape, hold down the mouse button and drag it to increase or decrease the size.


Table: shortcut keys for formatting

Action Select all Copy Cut Paste Undo Redo Bold Italics Underline Left justified Center justified Right justified

Key Shortcuts CTRL+A CTRL+C CTRL+X CTRL+V CTRL+Z CTRL+Y CTRL+B CTRL+I CTRL+U CTRL+L CTRL+E CTRL+R

PowerPoint provides so many choices for the appearance of text object on slide. You can change the size of the text, change the font of the text and can make the text bold or italic. You can also fill colour to background of the text, shadow the text and text colour.

To make text bold, italic 1. the

Select the text object, to enables additional tools in the toolbar for changing appearance of the text.

2.

Click the bold or italic button to changes the text. Italic Bold

Shadow

Underline


Change the font, size and color 1.

Select the text object.

2. Select font from the fonts list box of the toolbar to change the appearance of the text.

3.

Select size from the size list box of the toolbar to resize the label text.

4.

Using the mouse pointer to resize the control.

To fill the text background colour •

Select the text object.

•

Click on fill colour button to display colour list and select to fill it.


1.3.2 Working With Graphic Tools The Drawing Toolbar provides many commands for creating and editing graphics. The toolbar is located at the bottom of the Power Point screen or it can be activated by selecting View Toolbars Drawing from the menu bar.

Item No.1

Item No.19

The above shown figure of drawing toolbar is explained right to left, the first component is Draw Menu. 1. Draw Menu further contains mainly grouping, ungrouping, ordering, rotate or flip as given below: •

• • • •

Grouping: Images can be grouped together so they become one image and can be moved together or the same formatting changes can be applied to both at once. This section is further explain with an example in next section. Order: The order of overlapping images can be changed using this feature. Send backward and Bring Forward will move elements by one layer. Nudge: Use the nudge actions to move an object slightly in one direction. Align: Use to change the position of the objects in relation to one another. Rotate or Flip: Rotate an object 90 degrees or flip the object over its x- or y-axis.

2. Select objects: Deactivate all drawing functions.


3. Free rotate: This button will place green handles on certain objects so they can be arbitrarily rotated. Click and drag the handles to rotate the objects. 4. Next is AutoShapes menu: Click the small down arrow to the right of the "AutoShapes" text to select a shape. 5. Line and Arrow: Click and drag the mouse on the slide to add lines. Hold down the SHIFT key to draw a straight line. 6. Arrow: Similar to line only use the end points of the completed line to stretch and reposition the line. 7. Rectangle: Click and drag the mouse on the slide to add rectangles. Hold down the SHIFT key to add squares. 8. Oval: Click and drag the mouse on the slide to add ovals. Hold down the SHIFT key to add circles. 9. Text box: Click to draw a text box on the slide. 10. WordArt: Click to add WordArt. This is also similar to Word‘s WordArt 11. Picture: Click to add a clip art image to the slide. 12. Fill color: Choose a fill color for rectangles, ovals, and clip art. 13: Line color: Select a border color for shapes and pictures. 14: Font color: Highlight text on the slide and click the small down arrow next to the Font color icon to select a color. 15. Line style: Highlight a line or arrow that has been drawn and click this button to select a thickness or style for the line. 16. Dash style : Highlight a line or arrow and select a dash style. 17. Arrow style: Change the arrow head style for an existing arrow or change a line to an arrow. 18. Shadow: Select a text box to add shadow to text or choose any other object on the slide to add a drop shadow. 19. 3D: Add a three-dimensional effect to text and other objects.

1.3.3 Group or Ungroup The Objects You can create a set of object to group them and separate them by Ungroup.


To group the objects Select all the images that will be grouped by holding down the SHIFT key and clicking once on each image. Then select Group from the Draw menu. The images can be ungrouped by selecting Ungroup from the same menu. The rectangles in the image to the left are separate images with their own sets of handles and they are grouped together in the image to the right: •

Select the first object, press and hold down the Shift key and click on the second object to group with first object.

Grouped objects are treated as one single object To group objects: Select the objects you wish to group From the Draw menu, select Group


To ungroup objects Select Ungroup from the Draw menu •

Select Group from the Draw menu.

It will group the objects.

To Ungroup the objects •

Click on the grouped object to select. Select Ungroup from the Draw menu to Ungroup them

1.3.4 Animation in Presentation You can animate text, graphics, sounds, movies, charts, and other objects on your slides so that you can focus on important points, control the flow of information, and add interest to your presentation. You can set up the way you want text or an object to appear on your slide to fly in from the left, for example and you can set text to appear by the letter, word, or paragraph. You can also choose whether you want other text or objects to dim or change color when you add a new element. Also, you can change the order and timing of your animations, and you can set them to occur automatically without having to click the mouse. Several animations for slide objects are available through the drop-down menus on the menu bar. First, select the text box or graphic that will be animated. Select Slide Show Preset Animation and choose from one of the options. To select a different animation or turn the animation off, select the appropriate choice from the same menu. For more options, follow the procedure below:


Select Slide Show Custom Animation from the menu bar.

Select the object on the slide that will be animated from the Check to animate slide objects list.

Under the Effects tab, select the animation type (or select "No Effect" to turn an animation off) and direction from the drop-down menus and select a sound if you wish.

Select an After animation effect if the text should change colors after the animation executes.

Color palette - Select one of the color swatches or click More Colors for a larger selection. The text will change to the selected color when the mouse is clicked during the slide show.

Don't Dim - This option erases all After Animation effects.

Hide After Animation - Text will be immediately erased after the animation is completed.

Hide on Next Mouse click - The text will be erased when the mouse is clicked.

Choose the style of displaying the text under the Introduce text section. The drop-down menu provides options for displaying the characters for each bulleted item.

Click the Order & Timing tab to alter the order that the objects appear on the slide.


Click the Preview button at any time to preview the animation on the slide and click OK when finished.

Slide Transitions Add transition effects when changing slides by following these steps:

Select Slide Show Slide Transition from the menu bar.

From the Effect section, choose a transition from the drop-down menu and notice the preview after the transition is selected. Select a speed for the transition as well.

Under Advance, check "On mouse click" for the slide transition to occur by clicking the mouse or using keystrokes or check "Automatically after" and a number of seconds if the transition should occur automatically.

Select a Sound if necessary and check the Loop until next sound if it should keep repeating until the next sound is played.

Click Apply to All if the transition effects should be added to every slide or Apply if the effects should be added only to the current slide.

1.3.5 SLIDE SHOW The most common method of presenting your slides is slideshow. You can use all of the PowerPoint special effects and features to make an online (electronic) presentation exciting and complete. You can use such things as slide transitions, timings, movies, sounds, animation, and hyperlinks. After you decide that you are going to use a computer to give your presentation, you have many options on how to deliver it. To Start a slide show from within PowerPoint, you can Click Slide Show at the lower left


of the PowerPoint window (also shown in the figure). OR On the Slide Show menu, click View Show. OR On the View menu, click Slide Show. OR simply Press F5.

Save Presentation in slide show mode Open the presentation you want to save as a slide show. On the File menu, click Save As. In the Save as type list, click PowerPoint Show. The extension for a file saved as a slide show is .pps. When you open this type of file from your desktop, it will automatically start as a slide show. PowerPoint closes when the show ends, and you return to the desktop. If you start the show from within PowerPoint, the presentation opens and can be edited. Projector Wizard If you are presenting in a large room by using a monitor or projector, PowerPoint has a Projector Wizard that will automatically set and restore correct screen resolution for the target projection system. Self-running Presentation You might want to set up a presentation to run unattended in a booth or kiosk at a trade show or convention. You can make most controls unavailable so that users can't make changes to the presentation. A self-running presentation restarts when it's finished and also when it's been idle on a manually advanced slide for longer than five minutes. Pack and GO When you want to run a slide show on another computer, you can use the Pack and Go Wizard to pack your presentation. The wizard packs all the files and fonts used in the presentation together on a disk or network location. When you intend to run your


show on a computer that doesn't have Microsoft PowerPoint installed, you have the option of including the PowerPoint Viewer. You can include linked files as part of your package, and if you use TrueType fonts you can include them as well. If you make changes to your presentation after you use the Pack and Go Wizard, just run the wizard again to update the package. After you pack the presentation, you can unpack the presentation to run on another computer.To Pack up a presentation for use on another computer do the following steps: 1. 2. 3. 4.

Open the presentation you want to pack. On the File menu, click Pack and Go. Follow the instructions in the Pack and Go Wizard. If prompted, insert another disk.

1.3.6 Print the Presentation You can print your entire presentation the slides, outline, notes, and audience handouts in color, grayscale, or pure black and white. You can also print specific slides, handouts, notes pages, or outline pages. If you select Handouts view from print what option, you can then select a number of slides per page and whether the order should be horizontal or vertical. Most presentations are designed to be shown in color, but slides and handouts are usually printed in black and white. You can preview how your slides and handouts will look in black and white and adjust the look of black-andwhite objects before you print your presentation. If you are interesting to take print all the text in your outline or just the slide titles you can opt for outline view from print what option. You can also make color or black-and-white overhead transparencies from your slides, you can create 35mm slides by using a desktop film recorder, or you can create a file for a service bureau.


SUMMARY This unit showed you how PowerPoint gives you a way to produce a professionallooking presentation. PowerPoint views can be divided into Slides, Handouts, Speaker's Notes and Outlines. Similar to MS-Word in this tool of MS-Office also you can show or hide the toolbars from the Toolbars dialog box. These toolbars are useful for different quick text formatting, drawing and graphical work. Like, you can change the fonts, size and color of text. You can add drawing objects in your slide by select the drawing shape from the drawing toolbar. To work with objects move an object, align objects and group or ungroup objects. In last of the unit you learnt about different methods of delivering and printing your presentation slides.

Check Your Progress 3 Question 1: Draw the following in your Presentation.

CEO Accounting

Finance

Marketing

Manufacturing

HR

R&D

IT


Question 2: Insert the following objects in your presentation from clipart gallery and group the as given below.

Question 3: Pack your presentation using Pack and GO wizard. Question 4: Print your presentation handouts except the first page using. Each page cannot have more than 4 slides.

FURTHER READING • • • • • • •

Fundamentals of Information Technology by Alexis Leon and Mathews Leon;Leon Tech World Publication;1999 Computer Fundamentals by Dr.Larry Weng;Wiley Dreamtech Publications;2004 Computer Today by Suresh.K.Basandra;Galgotia Publications;2003 http://www.eiu.edu http://www.neiu.edu http://public.pacbell.net/faq/general_faq.html http://office.microsoft.com/powerpoint


DATABASES Structure 1.0 1.1 1.2 1.3 1.4 1.5 1.6

Introduction Objectives Introduction to MS-Access Working with MS-Access Creating Database with MS-Access Interconnectivity Summary

Page No. 1 1 2 3 3 4 5

1.0 INTRODUCTION Databases are probably one of the most common use of computers to store and manage information. A database is a collection of data that is organized so that its contents can easily be accessed, managed, and updated. Databases are not specific to computers. Example of database we use in our daily life is phone book .It can store all sorts of information like Name ,Phone number ,address and allow quick searching. Databases allow adding, deleting, updating and retrieving of data quite easily, as well as sorting and searching. Databases were compact, fast, easy to use, current, accurate and were secure. Database is managed using a software called Database Management System(DBMS).The software allows the users to organize data into databases and helps in retrieving the data very quickly and easily. The examples of DBMS software are Microsoft Access, Oracle, Sybase etc. This unit attempts to provide you the basic skills of MS-Access database with a working knowledge of how to maintain and effectively utilize a simple database including database creation, integrity enforcement, query formulation, forms and report creation, etc.

1.1 OBJECTIVES After going through this unit, you should be able to: •

Create a simple Microsoft access database.

Creating tables and Enter /edit records.

Enforce integrity constraints on databases.

Design Select queries to display data.

Develop forms/reports using sample interface.

Find, sort data.

Connect MS-Access to different front-ends.

1


1.2 INTRODUCTION TO MS-ACCESS Let's start with basic terminologies used in this unit: Data: is the information needed to be stored electronically in such a way to easily use it later. Database: is a collection of related data in the subject of interest. Database Management System: is the software used to manage storing the data and inquire it. Examples of such systems are Microsoft Access, Oracle, DB2, MySQL, etc. Microsoft Access is a Relational Database Management System (RDBMS) from Microsoft . The relational data model specifies data stored in relations that have some relationships among them . It used to create small and midsize databases for the Microsoft Windows family of operating systems. It can also be used as a database server for a web-based application.In relational databases such as Sybase, Oracle, IBM DB2, MS SQL Server and MS Access, data is stored in tables made up of rows and columns. MS-Access provides you with the software tools you need to create and organize the data in a flexible manner . There are four major database components in Access namely Tables, Queries, Forms and Report. MS Access database consists of several database components. Tables : Tables are the main units of relational database where the actual data is entered. Tables consist of records (rows) and fields (columns). Queries : Queries are basically a mechanism that allow you to extract data based on the criteria you define about the data in a database. A query retrieves required fields, records, and summaries you want to see from a database. Forms : Forms provide a quick and easy way to modify and insert records into your databases.Forms are nice front ends for accessing the data that is stored in database tables or that is generated by queries. Reports : A report shows selected records in a user-designed format. Pages : A data Access page is a special type of Web page designed for viewing and working with data from the Internet or an intranet. This data is stored in a Microsoft Access database or a Microsoft SQL Server database. Macros : A macro is a set of one or more actions that each performs a particular operation, such as opening a form or printing a report. Macros can help you automate common tasks. For example, you can run a macro that prints a report when a user clicks a command button. Modules :In MS Access all code is stored in "Modules".A module is a collection of Visual Basic code for Applications. 2


1.3 WORKING WITH MS-ACCESS Like any other computer application, in order to use Microsoft Access, you must first install it. After installing Microsoft Access, then you can open it. To start Access, click on the Start button, then the All Programs menu, then move to the MS Office menu and finally click on the Microsoft Access 2003 menu item. Your screen should look like this.

The user can create a new database , or open up an existing database. In general, the first time one begins a project, Create a new file option should be used to create a blank database d. After that point, use the Open option to re-open the database created previously. By clicking Create a new file option the following screen will appear

3


By selecting Blank Database and clicking on the OK button, the following screen will appear in order to give the new database filename.

Fill in File Name as Employee.mdb and click on the Create button to create the database . The window for the Employee database should open as shown in the figure

4


Microsoft Access (MS Access) enables one to manage all important information from a single database file. Within the file, one can use: Tables to store your data. Queries to find and retrieve specific data of interest. Forms to view, add, and update data in tables. Reports to analyze or print data in a specific layout. In the Objects list, click Tables the following screen will appear

Click Queries the following screen will appear

5


Click Forms the following screen will appear

Click Reports the following screen will appear

6


Click Pages the following screen will appear

1.4 CREATING DATABASE WITH MS-ACCESS 1.4.1 WORKING WITH TABLES Creating a Table Using the Design View To create a table in Access using the Design View, double click on the "Create Table in Design View" item. The Table Design View will appear. Fill in the Field Name, Data Type and Description for each column/field in the table as shown in the figure

7


Define a primary key field before saving your table Click Save on the toolbar, and then type a name for the table. Avoid including spaces in your table name or using long names. Click View | Datasheet View to begin entering data in the table. Click View | Datasheet View to begin entering data in the table the following screen will appear

Create a table by using wizard •

• • •

When Microsoft Access first starts up, a dialog box is automatically displayed with options to create a new database or open an existing one. If this dialog box is displayed, click Access Database Wizards, pages, and projects and then click OK. If you have already opened a database or closed the dialog box that displays when Microsoft Access starts up, click New Database on the toolbar. On the Databases tab, double-click the icon for the kind of database you want to create. Specify a name and location for the database. Click Create to start defining your new database

8


Select the sample table that we want and then select the items we need into the new table.

Press next.

9


Enter the name of the table.

10


Enter the data into the table that was created through wizard.

11


Creating a table by entering the Data:

12


1.4.2 WORKING WITH QUERIES we use queries to view, change, and analyze data in different ways. You can also use them as the source of records for forms and reports. Creating a query in the design view:

13


If we want the details of only EmployeeID and Name then the query editor for this will be as follows:

14


Create a query using wizard:

15


16


1.4.3 WORKING WITH FORMS A form is nothing more than a graphical representation of a table. You can add, update, delete records in your table by using a form. NOTE: Although a form can be named different from a table, they both still manipulate the same information and the same exact data. Hence, if you change a record in a form, it will be changed in the table also. A form is very good to use when you have numerous fields in a table. This way you can see all the fields in one screen, whereas if you were in the table view (datasheet) you would have to keep scrolling to get the field you desire. Create a form in Design view:

17


Create a Form using the Wizard It is a very good idea to create a form using the wizard, unless you are an advanced user and know what you are doing. Microsoft Access does a very good job of creating a form using the wizard. The following steps are needed to create a basic form: 1. Switch to the Database Window. You can do this by pressing F11 on the keyboard. 2. Click on the Forms button under Objects on the left side of screen 3. Double click on Create Form Using Wizard 4. On the next screen select the fields you want to view on your form. Most of the time you would select all of them. 5. Click Next 6. Select the layout you wish 7. Click Next 8. Select the style you desire...HINT: if you plan on printing your form, I suggest you use a light background to save on printer toner and ink 9. Click Next 10. Give you form a name, and select Open the Form and enter information 11. Select Finish 12. You should see your form. To adjust the design of your form, simply hit the design button (same as with the tables), and adjust your form accordingly

18


19


20


21


1.4.4 WORKING WITH REPORTS A report is an effective way to present your data in a printed format. Because you have control over the size and appearance of everything on a report, you can display the information the way you want to see it.

Create a Report using the Wizard As with the Form, it is a very good idea to create a report using the wizard, unless you are an advanced user. Microsoft Access does a very good job using the wizard to create reports. 1. Switch to the Database Window. You can do this by pressing F11 on the keyboard. 2. Click on the Reports button under Objects on the left side of screen 3. Double click on Create Report Using Wizard 4. On the next screen select the fields you want to view on your form. Most of the time you would select all of them. 5. Click Next 6. Select if you would like to group your files. Keep repeating this step for as many groupings as you would like. 7. Click Next 8. Select the layout and the paper orientation you desire 9. Click Next 10. Select the style you desire...HINT: if you plan on printing your report, I suggest you use a light background to save on printer toner and ink 11. Click Next 12. Give you report a name, and select Preview the Report 13. Select Finish 14. You should see your report. To adjust the design of your report, simply hit the design button (same as with the tables), and adjust your report accordingly.

22


23


24


25


26


1.5 INTERCONNECTIVITY Using Visual Basic as a Front-End to MS-Access After launching Visual Basic and Opening a Standard Visual Basic Form, the following screen will appear

1) Create a Data Object (usually it is the second to last object on the toolbox. If you pass your mouse over, it will show Data).

2) Double click on the Data object to create an instance of the data object on your Form

27


3) With your property windows open (if it is not open go to view menu and select property window), select the data object (by clicking once). A window with the properties of the Data Object should appear. a. Associate a Database Name (mdb file) to the Data object. Associate the Northwind database (or any mdb file on your disk).

b. Associate a RecordSource (table) to the Data object. You can associate the Customers table of the Northwind database.

28


4) You will now create a TextBox Field for each field that you want to access from your database table. With the property windows open, select the textbox field. Create two textboxes by double clicking on the textbox template from the tools menus. After each instance of a textbox is created on your form, drag the textbox to the appropriate position on the form. a. For the Datasource property of the field, select the name of the Data Object you defined in step 2 (it is Data1 if you haven’t changed the name of the data object.. b. For the Data Field property of the textbox, select the appropriate field. Select customer If for the first textbox and contact name for the second textbox.

5) Run your program and click on the arrows to move to next record an previous record.

29


30


Session-1 (3 hours) Question 1:Create a blank database named LIBRARY. Question 2:Add the following fields to LIBRARY: • Accession Number • Title • Author • Publisher • Cost You can change the names of fields as per need. Also, assign appropriate data type and size to each field. Question 3:Add at least 10 records Question 4:Add two new fields to the above table namely, Year of publication and ISBN number. Question 5:Add data to the two new fields for all the 10 records. Question 6:Create a Form consisting of all the fields of the LIBRARY. Assign the title BOOK INFORMATION to the form. Question 7:Create a Report consisting of all the fields of the LIBRARY. Assign the title REPORT ON BOOKS. Question 8:Create a Form using Visual Basic that can accommodate all the fields of LIBRARY. Question 8:Connect the form created in Visual Basic to LIBRARY in MS-Access Question 9:View the records of LIBRARY in the form.

1.6

SUMMARY

In this unit, MS-Access was introduced. Its various components as well as the process of working with it was explained. The process of creation of a database was demonstrated. Also, the process of creation of queries, forms and reports was also discussed. One of the most important features of any DBMS is its ability to connect to various front-ends. In this unit, the process of connecting Visual Basic to MS-Access is explained.

1.7 Further Readings

31


Access 2003 All-in-One Desk Reference for Dummies (Paperback) by John Kaufeld; 2003

Microsoft Office Access 2007 Inside Out by John Viescas and Jeffconrad;Microsoft Press; 2007

Access 2007 by Rutkosky; BPB Publications

http://office.microsoft.com/access

32


UNIT 3

INTERNET AND ITS APPLICATIONS

Structure 3.0

Introduction to Internet 3.1 Objectives 3.2 Telnet 3.3 FTP 3.3.1 FTP commands 3.3.2 Steps to get/put data from an anonymous FTP site 3.4 Gopher 3.4.1 Usenet 3.4.2 Classification of news groups 3.5 Web Browser 3.6 Search Engines 3.7 Google Search Engine 3.7.1 Components of Google Search Engine 3.7.2 Search tips using Google 3.8 E-mail 3.8.1 Steps to create E-mail account 3.8.2 Spam mail 3.8.3 Voice mail 3.9 Internet Chat Session 3.9.1 Instant Messaging 3.9.2 Voice chat 3.10 Blog 3.11 Internet Development Tools 3.12 Internet Security and Security Measures 3.13 Summary 3.14 Further Readings

3.0

INTRODUCTION TO INTERNET

Internet is a collection of million of computers and computing devices that are all connected using wire and wireless technologies with star, bus, ring or mesh topologies. Internet basically operates on TCP/IP protocol. With help of internet user can view results of examination, access bank account, view stock market details, news, sports, etc, Ftp allows user to download/upload files across multiple sites. Various web browsers provides facilities to search on a specific topic, have email account, logs, etc., Internet security can be provided by firewall and antivirus software. 3.1

OBJECTIVES

After studying this unit, the student is expected to be capable of the following: • • •

Knows about TELNET Knows about FTP Knows about GOPHER 1


• • • • • • •

3.2

Will be able to browse Internet Use search engines Able to give e-mail Able to chat Create a blog Exposure to Internet development tools Exposure to Internet security

TELNET

TELNET (TErminal NETwork) is a protocol that enables the user to log on a different system and use the resources. The different system (remote) can be located in same building, city, and country or geographically located in another place of the world. The system where the user works physically (local system) is called client and the remote system is called host. Therefore, telnet follows client/server model. To access the host system, user should know the IP address of that system. If user has login account and password on remote system, then it is called full-privilege telnet session, otherwise user can login as guest and share resources (files, memory and CPU) Restricted telnet connection is called anonymous/guest telnet session

3.3

FTP

FTP (File Transfer Protocol) is a protocol to transfer file(s) from local machine to remote machine or get file(s). FTP works on a client/server model. On the local machine FTP client is installed and on the remote machine FTP server is installed. Many FTP sites allow anyone to log on the server and download related files. Such ftp sites are known as Anonymous FTP. In restricted ftp sites, user should get login and password from the ftp server system.

3.3.1 FTP Commands account, append, ASCII, bell, binary, bye, case, cd, cdup, close, cr, delete, debug, dir, discount, form, get, glob, hash, help, lcd, ls, macdef, mdelete, mdir, mget, mkdir, mls, mode, mput, nmap, ntrans, open, prompt, proxy, sendport, put, pwd, quit, quote, recv, remotehelp, rename, reset, rmdir, runique, send, status, struct, sunique, tenex, trace, type, user, verbose

3.3.2 Steps to get/put data from an anonymous FTP site 1. FTP to access file in Berkeley education web site. Type ftp anarres.cs.berkeley.edu at command prompt. Login is anonymous and password is guest. Any one can access these files. Figure 3.1 depicts successful login.

2


Figure 3.1 2. Help at ftp prompt displays a list of ftp commands(figure 3.2).

Figure 3.2 3. ls displays list of files on Berkeley site; Here folders are pub and ucb(figure 3.3)

Figure 3.3 4. cd pub. Change directory to pub (public) directory and ls displays list of file on pub directory (figure 3.4)

3


Figure 3.4

5. cd algebra, change directory to algebra. ls –al, displays list of file in long format (figure 3.5)

4


Figure 3.5 6. pwd – print/present working directory. Binary to get/put files in binary mode and ASCII to get/put files in ASCII mode. lcd to display local directory path and get MixedVolume gets the file to local directory c:\. Disconnet to close the connection to Berkeley. put file.txt is valid, provided the anonymous user can put files on the destination site. Otherwise put is not valid(figure 3.6)

Figure 3.6 7. Once the ftp task is done, close/disconnect will close the web site connection and bye will terminate ftp session(figure 3.7)

5


Figure 3.7

3.4 GOPHER Gopher is a tool to search, download and display related data from various sites across the world. It is a client/server application similar to any web browsers. Presently, WWW is used with much more search facilities and options compared to gopher. A gopher space maintains all the related data of various fields . For a gopher session any one of the following are used: Browser for Gopher Client based gopher tool based on the operating system being used Archie – to search a file related to topic of interest. And later downloaded using FTP Veronia – Used to access all gopher space for a search also use other search engine features CWIS – Campus Wide Information Servers. Using gopher servers, data related to campus of school, university, office, banks, corporates can be maintained. Now-a-days much sophisticate www tools are used. WAIS – Wide Area Information Server. Using Veronia detail searching is not done and contents of documents are not referred. Using WAIS, details search can be done over more than 10,000 data bases.

3.4.1 Usenet Usenet is an application tool which enables the user(s) to join the user group(s) and chat or discuss on any topic of interest. These groups are called Usenet News Groups. There are more than 7000 Usenet groups. Each usenet site is maintained by news server and managed by administrator. Newsgroups are distributed around the globe through news servers.

3.4.2 Classification of news groups Comp - computer related features i.e. data bases, architecture, operating systems, games, etc., News - news related network like announce, questions and answers etc. Rec - recreational topics like sports, books, cinema, dance, music etc. Biz - business and management related features Soc - society related issues 6


sci - Scientific and technical features like physics, mathematics, chemistry, biology, etc. talk - group discussion and debate alt - wide range of subjects misc - miscellaneous topics 3.5

WEB BROWSER

An application that runs at user end and facilitates to access many internet resources like email, search engine, train/air reservation, examination results, net banking, online shopping, etc., Using URL, the corresponding web site is found. Web browsers operate using HTTP protocol. Browsers support text, audio, video, animation, etc., features for displaying web pages. Various types of web browsers are Microsoft Internet Explorer, Netscape Navigator, Mozilla, Konqueror, Firefox, Safari, Opera, Lynx, etc., With the help of web browsers user can access search engines, and access emails and use all the facilities of internet.

3.6

SEARCH ENGINES

Search engines provide the facility to search on any topic across many sites in various formats. Programs called spiders scan web periodically and maintain latest update in search engines. Search engine operates on the architecture of search query techniques. Various types of search engines are AltaVista, Aesop Search, ASK Jeeves, Direct Hit, Excite, Google, HotBot, Lycos, NorthenLight, SearchKing, WebCrawler,Yep,etc., Each search engine is application specific and google search is wide generally used.

3.7 GOOGLE SEARCH ENGINE Images, Video, Maps, News, Shopping, Gmail etc. are components of Google search engine.

3.7.1 Components of Google Search Engine 1. Browse to http://www.google.com . Search can be done using in any regional or national languages like Hindi. Default language is English (figure 3.8).

Figure 3.8 7


2. To search for any image on any topic, click on Images on http://www.google.com (figure 3.9).

Figure 3.9 3. To locate any part of the city in any country across the continents, click on Maps on http://www.google.com (figure 3.10).

Figure 3.10 4. To track latest news in various countries, click on News on http://www.google.com (figure 3.11).

8


Figure 3.11 5. With Orkut, user can create a community of friends and share text, audio, video and instant message. Orkut mobile helps user to communicate through VoIP (figure 3.12).

Figure 3.12 6. Google Scholar is an advanced search engine useful for researchers to search for articles etc. (figure 3.13).

9


Figure 3.13 7. Google Translator will translate text from/to any language(figure 3.14).

Figure 3.14 8. Google YouTube to share, upload and view video clips. Video clips can be any movie clip, user generated sequence of slides, TV clips or any clips. YouTube has video clips with audio facilities in built. Browse to http://www.youtube.com (figure 3.15)

10


Figure 3.15

3.7.2 Search tips using Google For searching for any topic user has to type the relevant text and click on search option. Various options used in google search are: 1. Quotes ( “Mega Structures “ ) - Searches for exact string Mega Structures is shown in figure 3.16.

Figure 3.16 2. Exclude words ( Bio -Chemistry) – Searches for Bio and not related to chemistry (figure 3.17).

11


Figure 3.17 3. Similar words (~Wireless) – Searches for words like mobile, cell, laptop, cellular, etc. (figure 3.18).

Figure 3.18

4. Multiple Words (Quantum OR Nano Computing) – Searches for quantum or nano computing (figure 3.19). 12


Figure 3.19 5. Range (Global climate change 2001 … 2005) – Searches for global climate change from 2001 to 2005. 6. Define (Define YouTube) – Searches for the definition of YouTube (Figure 3.20)

Figure 3.20 13


7. Site Specific (VLSI Design site:.edu)- Searches for VLSI Design in all educational institutions (figure 3.21)

Figure 3.21 8. Link Page (MCA Course: www.ignou.ac.in) – Searches for MCA in ignou web page (figure 3.22)

Figure 3.22

14


3.8

E-mail

E-mail is Electronic Mail. E-mail works on Simple Network Management Protocol (SNMP). Using e-mail we can send text, audio and video files to one person or a group of persons. Free E-mail can be created in Google, Yahoo, Hotmail, Netscape, Lycos, etc., the following shows sequence of steps to create email account in Gmail which is a part of Google.com. To create email account in yahoo site, hotmail site or any other site same sequence of steps can be followed

3.8.1. Steps to create E-mail account Steps to create E-mail account in Gmail from Google site: 1. In Internet Explorer or any other web browser, type www.google.com and at top right corner click on sign in option and the page as shown in figure 3.23 appears.

Figure 3.23 2. Click on Create an account option and fill your personal details, as shown below. Here first name is Student, last name is IGN. Desired login name is student, and password is given by user and kept confidential (figure 3.24).

15


Figure 3.24 3. Security question can be entered as given by gmail or user can have his/her own question and answer should be given in the below answer option In case user forgets his/her password, gmail will prompt user this question, and user should give the correct answer given by him, otherwise gmail will not access use to login to the system. Word verification meant for confidentiality, so that no automated tool can create user email account (figure 3.25). 4. After reading terms and conditions, finally user has to click on I accept create my account option and his email account is created (figure 3.26). 5.

Figure 3.25

16


Figure 3.26 Therefore, account of studentign has been created. The various components of e-mail are explained below: 1. Inbox - Consists of new mail that is not seen and old seen mails in a page. Inbox is located on left column of gmail. Once the user clicks on the new mail received, content of the mail is seen on new window (figure 3.27).

Figure 3.27 2. Compose Mail – Meant of composing a mail to a person or group of persons. In To: recerver’ s email identity (studentignmca@gmail.com) is written Subject: Welcome you or any other subject regarding user and content of message is written Message Box: Here the content of the message is written and fonts, size and color can be changed. Once the message is typed, send button at top of In Box is clicked and message is send to the receiver (figure 3.28).

17


Figure 3.28 3. Sent Mail – Gives a list of messages sent by user studentign (figure 3.29).

Figure 3.29 4. Trash – Consists of list of mails deleted(figure 3.30)

Figure 3.30 18


5. Contacts – Helps the user to add user name and their email address, postal address, phone numbers,etc., of their friends, family members, etc. (figure 3.31).

Figure 3.31 6. Settings Change - Click settings option on top right corner of the window to modify/update user account settings (figure 3.32).

Figure 3.32

3.8.2 Spam mail Spam is unsolicited junk email send my commercial companies for advertising or by any unknown person sending email through know email address. Spam decreases email traffic due to the capacity of unnecessary email flooding. Few spam mails can be detected and for bulky of spam mails it is more difficult to detect who actually is sending the spam. Web sites provide spam filter to restrict unnecessary emails to your system.

3.8.3 Voice mail 19


Normal e-mail has text, animation and images files. In voice e-mail, the user must record his/her voice and send. When the receiver opens the e-mail, voice is heard. At both the ends voice mails need the audio hardware.

3.9 INTERNET CHAT SESSION Chat is meant for live discussion using text and multimedia features. On the left bottom of the window, click on chat option; add user email identity with whom we want to chat. Confirmation comes from the recipient and the chat becomes a two way process. Internet chat provides a facility to have live chat between many persons or group of persons. It is a multi way chat technique. Internet Relay Chat (IRC) provides the facility of internet chat. Each chat group has as separate channel maintained my IRC architecture. It is normally not meant for one-to-one chat.

3.9.1 Instant Messaging Mainly meant for one-to-one private communication through messengers or SMS services in mobile phones. Using instant message text, picture can be send. Tools that provide instant message features are Microsoft Messenger, Netscape AOL Instant Messenger, Yahoo Messenger, etc,

3.9.2 Voice Chat In instant message we can send message, but in voice chat we can have live audio communication between two persons or group persons using the features of IP telephone and VoIP (Voice over IP). Many messenger tools support the feature of voice chat also.

Let us assume there are two users given below want to login: 1. Student-MCA 2. Student-IGN For these two users, email account has to be created in any email provider (yahoo mail, gmail, hotmail, etc.,) and their respective email identity should be added in each chat options. 1. Figure 3.33 shows a live chat between two students

20


Figure 3.33 2. Using left bottom option users can start voice chat and/or video chat. In this slide, both the systems do not have audio and video peripherals, as the text appears on the chat area (figure 3.34).

Figure 3.34 3. Users can use smiley faces for better dialogue (figure 3.35).

21


Figure 3.35 4. Above three slides indicate a separate chat window for each user. Here the chat window is docked out to gmail user, to have full length chat. Docked option is shown with middle arrow option on right top of chat window. Once the user minimizes the chat window, it gets docked in to the gmail window as given below (figure 3.36).

Figure 3.36

3.10 BLOG A blog is a type of internet website, usually maintained by an individual or a small company with frequent entries to descriptions of their interest, events, news, game, movies or to any person sharing his/her views. Material such as text, graphics, audio and video can also be shared using blog. Blog is normally a one way communication, where user gives his ideas or comments on that blog site. There are various types of blogs like science blog, social blog, movie blog, political blog, news channel blogs, etc.

3.11 INTERNET DEVELOPMENT TOOLS 22


Java – A programming language enables to run applications from internet. Java applets provide the facility of GUI and audio/video features. Supports various types of operating systems and it is operating system independent. Active X – Active X components and controls are downloaded and run on the computer. Active X supports all features of internet. IE supports Active x technology. JavaScript - Script for internet application to create forms, tables and GUI components. Java script lacks the complexity of programming skills. Java script can call components create by Java programming. ASP and .NET also enhances the development of internet.

3.12 INTERNET SECURITY Computer viruses provide major threat to the system and hamper users work. Memory and data gets lost and corrupted. Virus slows down CPU and I/O performance. Virus attack systems data from internet or portable devices like pen drive, CD/DVD drive, etc. The solution is to have full updated antivirus software. Cookies are bits of data put on disk when someone visits web site. Cookies keep track of user login and password and list of files opened by the user. Hackers can access the cookies and trace personal details about the person. The following are some of the security measures possible: • • •

Access control software – Software should be license certified and permission should be given to users having login accounts Antivirus software – Various types of antivirus and spyware software are to installed to keep system secure Firewall – Acts as a protection between computer and external network. Firewall can be a combination of hardware and software. It is normally installed on the servers and routers. List of web sites can be listed in the firewall table, restricting unwanted programs to access the system. User login and password – Only users having login and password should use the systems. Users should not be given any administrator permission to modify any files.

Session-1 (3 hours) Question 1: Search for information on CIT programme using atleast two search engines. Question 2: Download a video related to the topic titled “How to browse Internet” or any other technical topic of your interest from Internet. Question 3: Create an e-mail account using any website which enables creation of free e-mail accounts. Question 4: Create your own blog, include information about the seven wonders of the world on it. Question 5: Chat with any of your friends. 23


3.13 SUMMARY This unit gives practical idea of Internet and their applications. Using FTP user can download/upload any file from .edu or any other site. Main functionality of Web Browsers are explained. Various features of Google search engine and its option are explained with screen outputs. User can try these and get familiar with google search options. Various steps to create email account in google are given and the same may be followed for any email provider. Chat, instant message and voice chat are explained briefly. Definition of blog and its applications are given. Further, various types of programming development tools are mentioned briefly to enhance the feature Internet and its applications. Lastly, Internet security and various security measures are explained.

3.14 FURTHER READINGS • • • •

Internet 101: A Beginner’s Guide to Internet and World Wide Web by Elizabeth Castro and Wendy G Lehnert; 1998; Addison Wesley Publications How the Internet Works:Millenium Edition by Preston Gralla, Sarah Ishida, Mina Reimer and Stephen Adams; Techmedia Publications http://www.google.com http://www.wikipedia.org

24


UNIT 4

WEB PAGE DESIGN

Structure 4.0

4.3 4.4 4.5 4.6 4.7

Introduction 4.1 Objectives 4.2 Basics of web page design using HTML 4.2.1 Method to create and view the web pages in browser 4.2.2 HTML Basic tags 4.2.3 Image tags 4.2.4 Frames 4.2.5 Forms JavaScript and VBScript Features of Microsoft Expression Web Web Site Design Scripting Tools Summary Further Readings

4.0

INTRODUCTION

This unit explains the process of design of web pages. Web pages can be created by using HTML. However, to create pages with rich features, you need to use advanced DHTML, XML etc. In this unit, we confine to the creation of web pages using HTML. Using HTML, it is also possible to add images etc. to a web page. A web page can be frame based. A web page can also have forms as part of it which can be designed using HTML. JavaScript and VBScript facilitate validation. Though JavaScript and VB Script have several features which perform more tasks apart from validation, we do not dwell into them as they are beyond the scope of the unit. One of the tools that can be used to develop web pages is Microsoft Expression Web. Also, explained in this unit are some scripting tools in brief. 4.1

OBJECTIVES

After studying this unit, you should be able to • Know about basic HTML • Create simple web pages using HTML • Insert images into web pages • Create simple frame based web pages • Design forms • Know the features of Microsoft Expression Web • Know about various scripting tools 4.2

Basics web page design using HTML

HTML is a markup language used to create hyper texts that are platform independent. Markup feature can be links to other web pages, e-mail, multimedia, documents, databases etc 1


Structure of HTML A html file consists of two sections • Head • Body Tags are used in to identify each sections like head, body, title, paragraphs, tables, images, etc., Syntax of HTML tags: <tag name> Text Contents </tag name> Head begins with <Head> tag and ends with </head> tag. Title begins with <Title> tag and ends with </Title> Body begins with <body> tag and ends with </body> Heading tags start form <H1> to <H6> and ends with </H1> to </H6> The names of tags are not case sensitive.

Syntax of HTML file <! Comment for html file > <head> <Title> This text will appear on the window title </Title> <Body> Html statement 1 Html statement 2 Html statement 3 …………………. Html statement n </Body> </head> Each statement can be of type as follows: • Headings • Paragraph text • Table • Anchor to some other page, image, audio/video file, etc., • Multimedia (audio, video, image, animated image) • Forms • Frames 4.2.1

Method to create and view the web pages in browser

2


Writing HTML file HTML files are written in any editors like edit (at command prompt), Notepad, WordPad or any editor. Once the contents of html are written, the file should be saved as filename.html. Viewing the contents of HTML file The output of html file is viewed using Internet Explorer, Modzilla, and Opera, Mosaic or any internet browsing tools. Steps to see the output of html file: 1. Go to File option and select the open option 2. Browse the html file and select html file 3. Click on OK to see the output of html file in internet explorer or any other browsers. A web page contents has headings, paragraphs, tables, images, frames, etc. The headings in html are defined from H1 to H6 with the size of heading in H1 large and size of heading in H6 small. The following example gives an illustration of H1 to H6. Example 1: Write a html file with title “Welcome to HTML World�, display headings H1 to H6 Solution: HTML code 1. Using Notepad, type the following: <head> <Title> Welcome to HTML </Title> <Body> <H1> The size of HTML heading is H1 <h1> <H2> The size of HTML heading is H2 <h2> <H3> The size of HTML heading is H3 <h3> <H4> The size of HTML heading is H4 <h4> <H5> The size of HTML heading is H5 <h5> <H6> The size of HTML heading is H6 <h6> </Body> </head> 2. Save the file with webpage1.html ( or any name with .html extension) 3. Click Internet explorer or any browser. Go to File option and Open the file webpage1.html (refer to figure 4.1, figure 4.2, figure 4.3, figure 4.4)

3


Figure 4.1

Figure 4.2

Figure 4.3

Figure 4.4

4. Click OK and the output appears as shown in figure 4.5.

Figure 4.5 4


4.2.2

HTML BASIC TAGS

The following are Paragraph and Line break tags. Paragraph tag <p> is used to start a new paragraph or to end a sentence and start a new paragraph. For paragraph tag </p> is not mandatory. Line break <br> is used to break a line i.e have empty/blank line Example 2. Write a html file to illustrate paragraphs and breaks Solution: HTML code The sequence of steps is same as example 1. The contents of html file are <head> <Title> Welcome to HTML World </Title> <Body> <h3> About Web page! </h3> <h4> <p> A collection of related Web pages is called a Web Site. Web sited are housed on Web servers, host computes that store thousands of web pages. Copy a page onto the server is called as posting or uploading or publishing. Generally it is called uploading. Copy a page from server to the user’s computer is called downloading. <br> <br> Posting is generally used with newsgroups internet. <br> <p> Web pages are used to distribute news, travel information, banking, education, etc. </h4> </Body> </head> The output is shown in figure 4.6.

Paragraph

Break Horizontal row

break break Paragraph Figure 4.6

5


The common HTML tags for text formatting are shown in table 4.1. Tag symbol <!> <b> <i> <u> <ol> <ul> <li> <tt> <strike> <sub> <sup> <big> <small>

Description Comments to html code and will NOT appear in the webpage, meant for html writer. Bold text Italic text Underline text Ordered list Unordered list List item Typewrite font Strike through Subscript Superscript Big font Small font Table 4.1

Example 3. Design a web page to illustrate features of table 4.1. Solution: HTML Code Using Notepad, the following html code can be typed and saved as webpage3.html. The output is shown in figure 4.7. <! This html web page illustrates tags of table 4.1> <head> <Title> HTML Tags Table 1 </Title> <Body> <b> Unordered List </b> <ul> <li> One <li> Two <li> Three <li> Four </ul> <i> Ordered List </i> <ol> <li> One <li> Two <li> Three <li> Four </ol>

Figure 4.7

<! Nesting of List > 6


<u> Nesting of Lists </u> <ol> <li> One <li> Two <ul> <li> Two sub item unordered <li> Two sub item unordered </ul> <li> Three <ol> <li> Three sub item one <li> Three sub item two </ol> <li> Four </ol> </Body> </head>

Anchor tag is demonstrated in the following example. In web pages often some words needs further explanation, and anchor tag can be used to link current web page to other web page or document or short notes or multimedia application. Wherever there is an anchor tag, hand symbol appears and when the user clicks on it, the corresponding page is opened. Example 4: Write html file using anchor tags Solution: HTML Code <head> <Title> Anchor Tag </Title> <Body> In web pages often some words needs further explanation, and anchor tag can be used to link <br> current web page to other web page or document or short notes or multimedia application. <br> Wherever there is an anchor tag, hand symbol appears and when the user clicks on it, the corresponding page is opened. <br> <br> The following anchor which is underlined gives <a href = "webpage3.html"> Ordered and Unordered List </a> illustration </Body> </head> The output is shown in figure 4.8.

7


Figure 4.8 Text can be aligned as shown in following tags: <h2 align=center> This is centered text </h2> <h2 align=justify> This is justified text </h2> <h2 align=left> This is left text </h2> <h2 align=right> This is right text </h2> Handling tables Table is used to display data in row and column order. Splitting of rows and columns is also supported in html. Various types of tags in table handling are as given in table 4.2. Table Tag <table border> <tr> <td>

Description Table border with width, cell padding and cell spacing attributes Table row with column and row span Table descriptor with align, row and column span attribute Table 4.2

Example 6: Write code in HTML to illustrate table tags. Solution: HTML Code <html> <head> <Title> Table Example using HTML </Title> </head> <Body> <table border=3> <caption> <Big> List of Car Prices </caption> <tr> <th colspan=2> <b> Maruthi 8


<th colspan=2> <th colspan=2>

Hyundai Tata </b>

<tr> <th> Model <th> Price (Rs) <th> Model <th> Price (Rs) <th> Model <th> Price (Rs) <tr> <td> Classic 800 AC <td> 3,00,000 <td> Sonata Gold <td> 16,50,000 <td> Indica <td> 3,20,000 <tr> <td> Esteem <td> Santro <td> Indigo

AC <td> 5,00,000 <td> 4,00,000 <td> 4,50,000

<tr> <td> Versa AC <td> Getz <td> Indigo Max

<td> 4,50,000 <td> 3,50,000 <td> 6,50,000

</Body> </html> The output is as shown in figure 4.9. Figure 4.9

4.2.3

Image tag

Attributes of image are src, height, width, align, alt Align can be set as left, right, middle, top, text top, abs middle, baseline or bottom Example 5: Display image bluehill.jpg with width=150, height=250, hspace=25, vspace=25 Solution: HTML code <! To display image > <html> <head> <Title> Blue Hills </Title> </head> <Body> <h1> Blue Hills </h1> <hr size = 4> <img src="c:\blue hills.jpg" align=left width=150 height=150 hspace=20 vspace=20> </img> <br clear=left> Blue hills provide a good healthy and environment and close to nature. It is right in herbal plants useful for all species of life. 9


<hr size=2> <h1> Bordered Sunset </h1> <img src="c:\Sunrise.jpg" align=left width=150 height=150 hspace=20 vspace=20 border=5> </img> Sun rise wishes all of a good and happy day. </Body> </html>

Figure 4.10 The output is depicted in figure 4.10. Animated gif images can be downloaded from internet with .gif as extension. Syntax to insert animated Gif in html file: <img src=”animated.gif” alt=”text message” width = w height =h hspace= hs vspace =vs> To insert anchor with animated gif the following syntax can be followed: <a href=”Animation Concept”> <img src=”animated.gif” alt=”text message” width = w height =h hspace= hs vspace =vs> </a> Syntax to insert movies in html file: <embed src = “movie.mov” width =”w” height=”h”></embed> Syntax to insert sound in html file: <embed src = “sound.mp3” autoplay=true></embed>

10


4.2.4 Frames Window is called a container and can be divided in number of areas and each area is called a frame. Each frame has a name, can have html code and size can dynamically once the window area gets modified. The following HTML code divides frame as two columns of size 50% and 50% <frameset cols=”50%,50%”> ----------------------</frameset>

50% Left Frame

50% Right Frame

Figure 4.11 The following HTML code divides frame as two columns of size 50% and 50% and right frame to further 40% and 60% as shown in figure 4.12. <frameset cols=”50%,50%”> -----------<frameset rows= "40%, 60%"> --------------------</frameset> </frameset>

40% topframe

50% Left frame

60% Bottomframe Figure 4.12

Example 6. Write html file to display the frame shown above Solution: HTML Code This example has main html file as cc.html and it has creates three frames and first frame contains html from c1.html, second frame contains html code from c2.html and third frame contains html from c3.html. The output is shown in figure 4.13. cc.html <html> <head> <title> Frame Illustration </title> </head> <frameset cols = "50%,50%"> <frame name ="leftframe" src="c1.html"> <frameset rows= "50%, 50%"> <frame name ="topframe" src="c2.html"> <frame name ="bottomframe" src="c3.html"> </frameset> 11


</frameset> </html> c1.html <html> <head> <title> Contents </title> </head> <body> <h1> Contents </h1> Travelling by car is easy and comfortable </body> </html> c2.html <html> <head> <title> Welcome </title> </head> <body> <h1> Welcome </h1> Select any text and you will be happy </body> </html> c3.html Figure 4.13 <html> <head> <title> Frame World </title> </head> <body> <h1> Frames </h1> This example has THREE frames </body> </html> 4.2.5 Forms Forms help to develop interactive applications. Dynamic html supports active interactive web applications. Forms can have the following features • Text with paragraphs • Drop down list • Dialog box • Check box, radio button • Buttons • Text Box 12


•

Text area

Example 7: Design a form with all the above features Solution: HTML code <! HTML Script for forms > <html> <head> <title>Form Example</title> </head> <body> <h2 align=center>Super Market Details</h2> <br> <hr size=2> Name of Item <input type="text" name="name"> <br> <br> List of Items <select name="lstitems" hspace="10"> <option> Household Items <option> Furniture <option> Electronic <option> Food Bazar <option> Gifts </select> <br> <br> Gift Items <br> <input type="radio" name="gift"> Sceneries <input type="radio" name="gift"> Crockery <input type="radio" name="gift"> Painting <br> <br> Select any one of the following <br> <input type="checkbox" name="g1"> Nokia Mobile <input type="checkbox" name="g2"> Samsung Mobile <input type="checkbox" name="g3"> Motorola Mobile <br> <br> Type message you have to give <br> <textarea name="txtarea" rows="5" columns="50"> </textarea> <br> <br> <input type="submit" value="OK"> <input type="Reset" value="Cancel"> </body> </html> The name of HTML file is form1.html. The output is shown in figure 4.14. 13


Figure 4.14 4.3 JavaScript and VBScript In this section, we describe JavaScript and VBScript. 4.3.1 JavaScript The Internet Explorer Web browser contains a JavaScript interpreter, which processes the commands written in JavaScript. Using JavaScript we can design web application much efficiently, and JavaScript is a scripting language and can call java applets and java components. This lab manual gives an idea of JavaScript using function in script file. The following section gives two examples using JavaScript. JavaScript consists a set of functions and data variable (if needed in the script). 14


Syntax of JavaScript <script language=JavaScript> // comments of JavaScript javascript statement 1; javascript statement 2; …………………….. javascript statement n; </script> <! Non JavaScript content> Example 8: To display string Welcome to JavaScript Solution: JavaScript code <html> <head> <title> JavaScript Example 1</title> </head> <body> <script language=JavaScript> document.writeln("<h2>Welcome to JavaScript </h2>" ); </script> </body> </html> The output is as shown in figure 4.15.

Figure 4.15

Various functions that can be used JavaScript To display alert messages alert('JavaScript Message Box Comes'); To prompt the user for inputs window.prompt("Enter first integer",""); 15


4.3.2 VBScript VBScript is fully compatible to internet explorer. Using VBScript, user can design buttons, menus, dialog boxes and interactive inputs. Awareness of Visual basic programming language can enhance VBScript features. Example 9: Give an illustration of VBScript to display message box. Solution: VBScript <html> <head> <title> VBScript Illustration </title> </head> <body> <script language=vbscript> MsgBox "Hello VBScript" </script> </body> </html> The output is shown in figure 4.16. Figure 4.16 4.4

FEATURES OF MICROSOFT EXPRESSION WEB

Using Microsoft Expresssion Web , it is possible to design websites which are having rich features. It is possible to import Adobe Photoshop files which will help in the creation of graphics for the website. It is possible to design websites which are compliant to existing standards using Microsoft Expression Web. With this tool, the website designer can separate the design aspect from content with cascading style sheets. It possesses drag and drop feature. Also, hierarchy of styles can be visualized. It becomes very easy to work with CSS (Cascading Style Sheets) using this tool. It provides templates catering to various categories which can be used to design websites. The power of ASP.net can be harnessed.

4.5 WEB SITE DESIGN SCRIPTING TOOLS Web server responds to client requests and provides resources (answers to queries etc.,).Web server maps URL to a file on server using HTTP platform independent protocols. Web serves also map various types of application protocols of TCP/IP protocol suite.

Various types of web servers are: • Microsoft Internet Information Services (IIS) • Microsoft Personal Web Server (PWS) • Apache Web Server (Free open source) ASP (Active Server Pages) 16


Interactive Web pages are created with both client and server scripting. Active Server Pages (ASP), a server-side technology that dynamically builds documents in response to client requests. Various data base queries are supported using ASP features. Perl (Practical Extraction and Report Language) A High-level programming tool to monitor large software projects and generate reports. CGI (Common Gateway Interface) A Standard protocol where users can interact with applications on Web servers. CGI provides a way for clients to interface indirectly with applications on the Web server. Python A cross-platform, object-oriented language that can be used to write large-scale Internet search engines, small administration scripts, GUI applications, CGI scripts, Tcl/Tk ,OpenGL, etc., PHP (Pre Hypertext Processor) Pre Hypertext Processor is mostly used for server side scripting languages for creating dynamic Web pages. PHP also provides support for a large number of databases. Session-1 (3 hours) Question 1: Study the Microsoft Expression Web 2 quick start guide at http://expression.microsoft.com/en-us/cc184877.aspx . For the following questions 2 to 5, use Microsoft Expression Web 2 preferably. Question 2: Design a web page which shows your resume. Question 2: Design a web page that shows a table consisting of marks of a student in six subjects. The table should also show the aggregate marks of the student. Question 3: Using JavaScript and VBScript, write code to add and multiply two numbers. Question 4: Design web pages that display images of reputed Computer scientists. Question 5: Design web pages that includes a link to a video clip. 4.6 Summary This section gives basic idea of html and functionality of various types of tags. Paragraph tags, table tags, image and multimedia tags etc., are explained briefly. Various examples are given and their respective screen outputs are given. Forms and frames play an important role for further development of a web page. To add the feature of dynamic content VBScript and JavaScript can be an added feature. Basic idea of this script is given. To design a web page Front Page tool can be used as ease and design process of web page becomes much simpler. For complete web 17


applications, web servers are needed. IIS, PWS and Apache Server can be used. Web designing tools like Perl, PHP, ASP, CGI, and Python enhance the features of web site design 4.7 Further Readings • • • • • • • • • •

Web Design Complete Reference by Thomas A. Powell; McGraw Hill; 2002. Internet & World Wide Web:How to Program by Paul J.Deitel and Dr.Harvey M.Deitel; Prentice Hall; 2007. Microsoft Expression Web 2 Step by Step by Chris Leeds; Microsoft Press; 2008 Sams Teach Yourself Microsoft Expression Web 2 in 24 hours by Morten Rand-Hendriksen; Sams; 2008. Microsoft Expression Web for Dummies by Linda Hefferman; For Dummies; 2007 http://w3schools.com/html http://www.html.net http://msdn.microsoft.com http://www.microsoft.com/expression For Microsoft Expression Web training videos, browse to http://expression.microsoft.com/enus/cc136535.aspx

18


Java Programming Lab

SECTION 5 JAVA PROGRAMMING LAB Structure 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7

Introduction Objectives Programming with Java PATH and CLASSPATH Setting Example Programs List of Lab Assignments Summary Further Readings

5.0 INTRODUCTION Only at the age of ten, Java became master of programming languages. Its interesting success has made Java the fastest growing programming language ever. It is a bouquet of different programming flowers, having peculiar smells, merging the beauty of all programming languages. You must work with this language to enrich your skill set and to become an expert programmer. In this section, a brief introduction to Java is given to understand the strength of the language you are going to work with. We have already explained the solution of some obvious problems that you may encounter in the first session while compiling and interpreting your first java program. We have also explained the compilation and interpretation of example programs using of freely available software called editplus.

5.1 OBJECTIVES After going through this lab section you will be able to: • • •

compile and interpret Java programs in DOS and editplus;. writes Java programs using sequential, conditional and iterative statements; handle arrays of fixed and variable size; 1


Lab Manual

• • • • • • • • • •

creating classes and objects using Java; implementing constructors and constructor overloading; solving problems using Inheritance and Polymorphism; create your own package and interface; handling exceptions arising in programs; use of multithreading in programs; work on strings; use GUI components in your programs; implement Sockets; and connect databases with your programs.

4.2 PROGRAMMING WITH JAVA The future of computing will revolve around the Internet. Java is a programming language developed by Sun Microsystems to take care of Internet computing requirements. Java is a platform independent language, that is why it is very popular for cross – platform applications and programming on Word Wide Web (WWW). Java is an Object Oriented Programming Language, which serves the purpose of Object Oriented Paradigm of Programming. An object oriented language uses the concept of abstraction, encapsulation, inheritance, and polymorphism to provide flexibility, modularity, and reusability for developing software. The following features of Java make it popular and a very useful programming language: Platform Independent: Java programs can run on any machine and operating system that support Java Virtual Machine as we are showing in Figure 5.1 where we have shown that a program after compiling converts into a byte code which is able to execute on any platform Windows/Linux/Macintosh. Multithreaded: These capabilities of Java provide the capability to single program to perform several tasks simultaneously. Multithreading is very useful for developing applications like animation, GUI, and networks. Unlike other programming languages, multithreading is integrated to Java. In other programming languages you have to call operating systems specific procedures to perform the task of multithreading. Distributed: Using Java programs simultaneous processing can be done on multiple computer on the Internet. Java provides strong networking features to write distributed programs. Secure: The design of Java has multiple layers of security which ensure proper access to private data and control over access to disk files. You will cover major topics of Java Programming in this lab section during problem solving including programming structures, methods objects, inheritance, exception handling, multithreading, AWT, I/O, and applets. Because you know C programming language, it will be easier for you to learn Java programming. It is very important to keep in mind the object-oriented features during problem solving. Java is also known as a Modern high-level language due to its characteristics: Simple, Architecture neutral, Object oriented, Portable, Distributed, High performance, Interpreted, Multithreaded, Robust, Dynamic, and Secure. The Java programming language is unusual in the sense that a Java program is both compiled and interpreted as shown in Figure 5.1.

2


Java Programming Lab

Compiler

BYTECODE

Windows

Linux

Mac

Figure 5.1: Execution of a Sample Java Program

Now let us see how you will run your Java programs‌

4.3 PATH AND CLASSPATH SETTING To run Java programs you need JDK (Java Development Kit) installed on your machine. The latest version of JDK you can download from java.sun.com for free. It is suggested that you should set PATH and CLASSPATH properly before trying to compile and run your Java programs, otherwise you may not able to compile or run your program because of improper setting. PATH Setting If PATH setting is not proper then whenever you try to compile any program on your DOS prompt as shown in Figure 5.2, it does not compile your TestProg program.

Figure 5.2: Compile TestProg.java

3


Lab Manual

Instead it gives you some strange message about a “Bad Command”. What’s wrong? Can you guess? You must be thinking that you did not install JDK correctly in your system but this is not correct answer. The machine says “Bad command” because it recognizes the commands javac or java. So you simply need to tell DOS that these commands live in Java’s JDK directory and whenever it doesn’t recognise a command like javac, it should also check the Java’s JDK directory for a possible interpretation of this command. This problem can be solved in two ways, one by using DOS prompt, and another by using My Computer on your window screen. Type path at your DOS prompt as demonstrated in Figure 5.3, you will get a PATH statement like PATH=C:WINNT\...;C:\ProgramFiles\.....

Figure 5.3: Showing PATH Statement

Here the dots represent all kinds of directory names. This is a list of all the places DOS looks when it is trying to find out what a particular command means. If your JDK directory is not on this list, your DOS won’t understand the JDK’s commands. So you need to add it to the list. You can do this by typing. set path=c:\jdkwhateverItIs\bin;%path% Whatever is the version of JDK, the above command adds your JDK directory to the rest of the existing path. If you have put your JDK directory somewhere else, alter the directory name in the command above appropriately to match the actual location. If there is any spaces in the command above (except between set and path), path will not be set properly. Now try to run the Java commands again. If it still doesn’t work, move your *.java files into the JDK directory and you should be able to work there (or in the bin subdirectory of the JDK directory). Here is the problem again because you’ll need to reset your path every time you turn your machine back on and want to work on the Java programs again. But there is a way to fix it permanently. You need to alter (edit) your autoexec.bat file, which is in your main C:\directory. It is suggested to copy this file first to a back up version, then do the required modifications as told here. C:\copy autoexec.bat autoexecBACK.bat This is the file that has all the important settings for making your PC run the way you want it. One of the settings it makes is the PATH. Now edit the autoexec.bat file and find the line that sets the path. Add your version of the "set path=C:/jdk.2...." command (the one you used earlier) after the line that sets the rest of the path in the autoexec.bat file. Now save the file. Then the next time you 4


open a DOS window (it maybe required to restart your machine), the PATH should be set correctly. If you made an error in editing autoexec.bat, things might not work quite right now. In this case, just copy your back up version of autoexecBACK.bat back into autoexec.bat and try the whole process again. CLASSPATH Setting You may also need to set the CLASSPATH variable, which contains all of the directories on your machine where the Java compiler and the Java run-time environment are to search for any files it needs, e.g., if you compile or run the Java class TestProg.java, the compiler needs to know that directory. Your autoexec.bat file or control settings also determine where the javac compiler looks for the Java code files. For example, if you are writing your code in the directory c:\jdk1.2\naveen, you would add the following line to your autoexec.bat file: CLASSPATH: c:\jdk1.2\naveen You can list (separated by ;) as many directories as possible in your classpath. One important thing about "." is that it means that javac will always look in the current directory for the files it needs. For example, to list the current directory, the naveen directory, and the diskette drive as places where javac should look, you would have the following classpath: CLASSPATH: .;c:\jdk1.2\naveen;a:\ This environmental variable can be set the same way as the PATH above. But there is one shortcut to avoid the CLASSPATH setting. The javac or Java command has an option that is (classpath option) that allows you to manually configure the classpath during compilation/execution. For example, to specify that the compiler must look in the current directory (that is, the "." directory) for the file TestProg.java when compiling it, you would use the command: javac -classpath . TestProg.java In XP/2000/ME machines PATH and CLASSPATH can be set using “My Computer.” The process is given as follows: 1. 2. 3. 4.

5. 6. 7.

Right click on "My Computer" and Click on Properties. Click on the Advanced tab. Click on the "Environment Variables" button near the bottom. A dialog box comes up with two boxes: In the bottom box, look for "Path" and highlight that line. Then click on "Edit" .A small dialog box appears. In the second text field for the value, at the END of the line, add a semicolon then the path to where your java.exe file is. For example path is like:C:\jdk1.3….\bin Click "OK." Now, in the top box, click on the "New" button. In the first field, enter "classpath" as one word. For the value in the second field, enter a single period.

This is all you have to do for setting PATH and CLASSPATH. Now you can compile and run your applications and applets without any problem of PATH and CLASSPATH. PATH and CLASSPATH setting need to be done only if you are willing to run programs on DOS prompt. If you write Java programs in some specific editors like EditPlus, JBbuilderfor etc. then these settings discussed above are editor dependent.

5

Java Programming Lab


Lab Manual

Now we will learn how EditPlus can be set for Java Programming. EditPlus is distributed as Shareware. You can freely download and try it for 30 days from http://www.editplus.com/download.html. 1. Open EditPlus and you will see the window similar to the Figure 5.4. 2. Select Tools–>Configure User Tools .You will find a dialog Window in which you have to select a Group Name. 3. Select Group1 as Group Name you can select any. 4. Click on Add Tool >> button and select Program. Setting for Compilation of Java Programs 5.

In front of Menu text: write Compile

Figure 5.4: Configure user tools of editplus

6. 7. 8. 9. 10.

In front of Command: browse and select C:\jdk1.3.0_01\bin\javac.exe or the directory where javac.exe file is located. (As shown in Figure 5.5) In front of Argument: select $(FileName) In front of Initial directory: select $(FileDir) Select Capture output box. Select Save open files box.

Figure 5.5: Setting editplus to compile Programs

6


Java Programming Lab

Setting for Running Java Application Programs

11. 12. 13. 14. 15. 16.

In front of Menu text: write Run (as shown in Figure 5.6 given below) In front of Command: browse and select C:\jdk1.3.0_01\bin\java.exe or the Directory where java.exe file is located. In front of Argument: select $(FileNameNoExt) In front of Initial directory: Leave black Select Capture output box. Select Save open files box.

Figure 5.6: Setting editplus to run Java Application Programs

Setting for running Java Applet Programs 17. 18. 19. 20. 22.

In front of Menu text: write AppletViewer (as shown in Figure 5.7 given below) In front of Command: browse and select C:\jdk1.3.0_01\bin\appletviewer.exe or the Directory where appletviewer.exe file is located. In front of Argument: select $(FileName) In front of Initial directory: Leave black Select Save open files box.

Figure 5.7: Setting editplus to run Java Applets

7


Lab Manual

Now you will find that three more items Compile, Run, and AppletViewer are added to the Tools menu of EditPlus. For Compile ctrl+1, for Run ctrl+2, and for AppletViewer ctrl+3 can be used. EditPlus is set to be used for Java Programming. Let us take one application and one applet Program running using EditPlus.

5.4 EXAMPLE PROGRAMS In this we will explain how to compile and run application program as well as applets. 1. 2. 3.

Write your program Welcome_Application.java in EditPlus as demonstrated in Figure 5.8. Compile using ctrl+1 button Run using ctrl+2 button

Figure 5.8: Compile and run application program in EditPlus

In case of Applet first you write applet as shown in Figure 5.9. 1. 2.

Compile using ctrl+1 button similar to the previous way. Run it using ctrl+3 button as shown in Figure 5.10 but take care you are applying ctr+3 on appropriate HTML file or not.

Figure 5.9: Compile applet in EditPlus

8


Java Programming Lab

Figure 5.10: Run applet in applet viewer using editplus

Session-1 (3 hours) Question 4: Write a Java Applet program which reads your name and address in different text fields and when a button named find is pressed the sum of the length of characters in name and address is displayed in another text field. Use appropriate colors, layout to make your applet look good. Question 2: Create an applet which displays a rectangle/string with specified colour & coordinate passed as parameter from the HTML file. Question 3: Create an applet which will display the calendar of a given date. Question 4: Write a program to store student’s detail using Card Layout. Question 5: Write a Java Applet program, which provides a text area with horizontal and vertical scrollbars. Type some lines of text in the text area and use scrollbars for movements in the text area. Read a word in a text field and find whether the word is in the content of the text area or not.

5.6 SUMMARY In the beginning of the section we aimed to provide you a first step assistance to Java programming. In this section, we discussed the basics and importance of working with Java. In the beginning of this section we laid emphasis on the most fundamental concepts and mechanisms provided by Java language. How you will start working on Java (starting from downloading jdk) this section provided you interactive guidance so you can start working on Java. We showed you how you can start compiling and executing your program using freely downloadable software known as editplus or DOS with the help of a suitable example. More stress has been laid on the compiling and executing of the first program and related troubleshooting. This enables better utilization of lab hours and learners will feel motivated to work with software without getting trapped in the problem (at least not in the beginning).

9


Lab Manual

5.7 FURTHER READINGS The following are the books and website references with you can use in your lab course: Books on Java 1. 2. 3. 4. 5. 6.

Java: An Introduction to Computer Science and Programming by Walter Savitch. Problem Solving with Java by Elliot B. Koffman and Ursula Wolz. Introduction to Programming Using Java: An Object-Oriented Approach by David M. Arnow and Gerald Weiss. David M. Arnow and Gerald Weiss, Introduction to Programming Using Java: An Object-Oriented Approach, Addison-Wesley. Ken Arnold, James Gosling, and David Holmes, The Java Programming Language (Third Edition), Addison-Wesley. Judith Bishop, Java Gently: Programming Principles Explained (Third Edition), Addison-Wesley.

Tutorials on web http://java.sun.com/docs/books/tutorial/index.html http://www.ibiblio.org/javafaq/javatutorial.html http://herzberg.ca.sandia.gov/JavaCourse/ http://www.sunncity.com/Tutorial_Java/partOne/start.html http://scitec.uwichill.edu.bb/cmp/online/CS24L/java/jdkintro.htm

10


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.